我最近更新了Laravel 4.1,並且退出的模式窗口窗體無法正常工作。在Laravel 4.1更新之後,我發現Laravel出於某種原因自動將標籤插入到我的模式主體中。 (我在頁腳中有Form :: close(),我只是好奇其他人是否已經看到了這一點,或者可以解釋爲什麼發生這種情況以及如何防止它發生。Laravel 4自動插入</form>
請注意,如果我將提交按鈕移動到模態體div中,然後按預期方式提交工作,並且更新將通過正常過程..但由於某種原因,使用此特定模式,在頁腳的提交按鈕將提交按鈕放在窗體的外部,因爲窗體close自動插入到modal-body div的末尾之前。另外奇怪的是,我在另一個頁面上工作,一切都按預期工作。
以下是相關代碼:
<div class="modal-body">
<?php
$access = Session::get('user_access');
$userid = Session::get('user_id');
?>
{{ Form::open(array('method'=>'POST','route' => 'users.store', 'style' => 'display:inline')) }}
@foreach($user as $userinfo)
<!-- Set hidden form element with userid embedded -->
<input type="hidden" name='id' id='id' value={{ $userid }}>
<!-- Display the username and profile Picture -->
<h2><center>{{ $userinfo->username }}</center></h2>
<br><br>
<!-- 2 Column Form to change user information and display current status -->
<div class ='container col-md-offset-1'>
<div class='row col-md-3'>
<div>
{{ Form::label('givenname', 'First Name:') }} <br>
<input type="text" name='givenname' id='givenname' value={{ $userinfo->givenname }}>
</div><br />
<div>
{{ Form::label('surname', 'Last Name:') }} <br>
<input type="text" name='surname' id='surname' value={{ $userinfo->surname }}>
</div><br />
<div>
{{ Form::label('email', 'Email Address:') }} <br>
<input type="text" name='email' id='email' value={{ $userinfo->email }}>
</div><br />
</div>
<div class='row col-md-3'>
<div>
{{ Form::label('password', 'New Password:') }} <br>
<input type="password" name='password' id='password' value={{ $userinfo->password }}>
</div><br />
<div>
{{ Form::label('password_confirmation', 'Confirm New Password:') }} <br>
<input type="password" name='password_confirmation' id='password_confirmation' value={{ $userinfo->password }}>
</div><br />
<div>
{{ Form::label('useraccess', 'Current Subscription Status:') }} <br>
{{ $access }}
</div><br />
</div>
</div>
@endforeach
</div> <!-- End Modal Body -->
<div class="modal-footer">
{{ Form::submit('Save', array('class' => ' btn btn-warning')) }}
<!-- Close the form -->
{{ Form::close() }}
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
當我在瀏覽器中運行的開發工具,我可以看到自動插入
<form method="POST" action="http://dev.app.myapp.com/users" accept-charset="UTF-8"><input name="_token" type="hidden" value="<TOKEN">
<!-- Set hidden form element with userid embedded -->
<input type="hidden" name="id" id="id" value="6">
<!-- Display the username and profile Picture -->
<h2><center>johndoe123</center></h2>
<br><br>
<!-- 2 Column Form to change user information and display current status -->
<div class="container col-md-offset-1">
<div class="row col-md-3">
<div>
<label for="givenname">First Name:</label> <br>
<input type="text" name="givenname" id="givenname" value="John">
</div><br>
<div>
<label for="surname">Last Name:</label> <br>
<input type="text" name="surname" id="surname" value="Doe">
</div><br>
<div>
<label for="email">Email Address:</label> <br>
<input type="text" name="email" id="email" value="[email protected]">
</div><br>
</div>
<div class="row col-md-3">
<div>
<label for="password">New Password:</label> <br>
<input type="password" name="password" id="password" value="Encrypted Password String">
</div><br>
<div>
<label for="password_confirmation">Confirm New Password:</label> <br>
<input type="password" name="password_confirmation" id="password_confirmation" value="Encrypted Password String">
</div><br>
<div>
<label for="useraccess">Current Subscription Status:</label> <br>
User </div><br>
</div>
</div>
</form>
<div class="modal-footer">
<input class=" btn btn-success" type="submit" value="Save">
<!-- Close the form -->
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
只是看起來像我的壞標記。你應該在'modal-body' div之外打開窗體,然後關閉它在'modal-footer' div的外部(底部)。所以基本上這個形式是包裝*一切*。 –
嘗試將打開的表單移動到模態標題,並且只是使它將模板標題插入到模態標題中...不明白爲什麼它的自動關閉表單..我有其他模式完全使用同樣的標記,在這裏我打開身體的窗體並關閉它在頁腳中,並按預期工作。 – rnason
如果您使用「查看頁面源代碼」,它仍然存在嗎? –