1
다른 게시물에서 여러 가지 솔루션을 시도했지만 여전히 작동하지 않습니다.Laravel 4에서 동일한보기의 두 양식
나는 페이지 (보기)의 두 가지 형태 나 데이터베이스에 버튼 아무것도 변화를 제출 쳤을 때
{{ Form::open(array('action' => '[email protected]')) }}
....// form fields
<button type="submit" class="btn btn-primary">Change</button>
{{ Form::close() }}
<hr/>
{{ Form::open(array('action' => '[email protected]')) }}
....// second form fields
<button type="submit" class="btn btn-primary">Save Changes</button>
{{ Form::close() }}
는 다음 경로에 내가
Route::post('/admin/preferences', ['uses' => '[email protected]', 'before' => 'csrf|admin']);
Route::post('/admin/preferences', ['uses' => '[email protected]', 'before' => 'csrf|admin']);
을 가지고 있습니다. 두 번째 페이지를 제출하더라도 첫 번째 양식에서 페이지가 새로 고쳐지고 성공 메시지가 나타납니다.
URL의 경로가 두 게시물에 모두 동일하기 때문입니까?
업데이트 첫째 양식 입력 필드 : 여기
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" <?php if ($settings['preferences_shop_mode'] == 0){ ?> checked="checked" value="1"<?php }else{ ?> value="0" <?php } ?>>
I 확인 선호 = 0 (1)에 값을 설정하는 경우, 그렇지 않으면 값 = 소스 0로 그 가치 때문에 데이터베이스에 정확 =1
것을 볼 나는이 컨트롤러
public function shopMode() {
$preferences = Preferences::where('preferences_id', 1)->first();
if (!$preferences) {
App::abort(404);
}
Input::merge(array_map('trim', Input::all()));
$preferences->preferences_shop_mode = Input::get('onoffswitch');
$preferences->save();
return Redirect::to('/admin/preferences')->with('message', 'Shop mode changed successfully.');
}
입니다
0
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked="checked" value="1">
이
데이터베이스에서 업데이트되지 않는 이유는 무엇입니까?
데이터베이스의 변경 사항을 제출하지 않는 대단히하지만 두 번째 양식을 주셔서 감사합니다 .. 나는 내 질문에 업데이트되었습니다. 확인해 주시겠습니까? –
그건 완전히 다른 질문입니다. 확인란의 동작은 나머지 부분과 다르며 선택하지 않으면 필드가 요청에 따라 도착하지 않습니다. [이 질문] (http://stackoverflow.com/questions/1809494/post-the-checkboxes-that-are-unchecked)을 보면 도움이 될 것입니다. 알려줘! – alariva
하지만 항상 가치가 0 또는 1입니다. 게시 될 때이 값을 받아야합니까? –