php - How to Validate a Html select Element with Laravel 5? -
i've got section list in viewlike this:
<select name="departments"> <option value="1">support 1</option> <option value="2">support 2</option> </select> now check if selected option value in database, users cannot sent incorrect number of support department.
how can access "value" in validator?
$validator = validator::make($request->all(), [ 'how access value?!' => 'required|exists:departments,id', ]);
i think there's misunderstanding of what's going on. it's not value need access, need tie name of element. let's see looks like:
'departments' => 'required|exists:departments,id' this make sure selected value exists in departments table on id column.
Comments
Post a Comment