Hello Everyone,
I have a from where i get some inputs from the user, i use same for for create and edit. In edit case i need to use hidden input field for some id reference purpose. But when i save using the save() method the hidden input field also passing into the database that gives me error.
Form :
Code:
<div class="mb-3 col-md-3">
<label for="division_id" class="form-label">Divison</label>
<select id="divisionId" name="division_id" class="form-select">
<option value="">Select</option>
</select>
<span class="error">
<?= session('emp_error.division_id') ?>
</span>
<input type="hidden" name="edit_division_id" id="edit_division_id" value="<?=isset($employee->division_id) ? $employee->division_id : ''?>">
</div>
Method :
PHP Code:
if($this->request->getPost() ) {
if ($this->model->save($this->request->getPost()) === false) {
return redirect()->back()
->with('warning', 'Please fix following errors.')
->with('emp_error', $this->model->errors())
->withInput();
}
else {
return redirect()->to('dashboard/employees')
->with('success', 'Employee record created');
}
How i can restrict the hidden fields passed into the save() method ?