我正在嘗試做一些事情,以便在選中復(fù)選框控件時可以上傳照片。我讓客戶端正常工作正常,使得檢查復(fù)選框時,將顯示上載控件,表單正確驗證。但是,在我的控制器中,如果我的復(fù)選框已選中(true),則調(diào)用某種方法需要采取一些措施。如果未選中(假),我將執(zhí)行其他一些操作。在我的html頁面中,我有以下內(nèi)容:<form action="/supplier/submit/plan" method="post" role="form" id="plan-form">... <input name="checkingPhotos" type="checkbox" id="chkPhotos" /> <label for="chkPhotos">I want to include photos in this plan.</label>...</form>但是,在我的控制器中,我現(xiàn)在只想看看我是否在復(fù)選框中得到了正確的值。為此,我做了一些簡單的事情: public function submitPlan(Request $request) { $checkboxValue = $request->input('checkingPhotos'); dd($checkboxValue); }null無論是否選中此復(fù)選框,都會打印結(jié)果。我的路線也看起來像這樣:Route::post('/submit/plan', 'SupplierController@submitPlan');有人可以告訴我我在做什么錯嗎?我只想在我的控制器方法中看到值1 / True或0 / False。
3 回答

寶慕林4294392
TA貢獻(xiàn)2021條經(jīng)驗 獲得超8個贊
如果是復(fù)選框,則應(yīng)將輸入名稱修改為
<input name="checkingPhotos[]" type="checkbox" id="chkPhotos" />
然后,您應(yīng)該能夠隨心所欲地獲得價值
$request->input('checkingPhotos');
- 3 回答
- 0 關(guān)注
- 173 瀏覽
添加回答
舉報
0/150
提交
取消