1
我有我的看法這一點,選項值默認
<div class="form-group">
<label for="theme" class="col-sm-3 control-label">Theme</label>
<select class="form-control" id="theme" name="theme">
<option value="0">Default Theme</option>
<option value="1">Dark Theme</option>
</select>
</div>
,並在我的控制器
/**
* Change User Account Settings
*
* @access public
* @return view user.settings
*/
public function changeSettings($username, $id)
{
$user = Auth::user();
if (Request::isMethod('post')) {
$user->style = (int) Request::get('theme');
$user->save();
return Redirect::route('profil', ['username' => $user->username, 'id' => $user->id])->with(Toastr::success('Your Account Was Updated Successfully!', 'Yay!', ['options']));
} else {
return redirect()->back()->with(Toastr::warning('Something Went Wrong!', 'Error', ['options']));
}
}
我怎樣才能使它如此選擇值默認爲用戶選擇什麼風格的選項在數據庫中?
感謝完美地工作 –