D
D
driverx182017-09-09 17:03:45
Laravel
driverx18, 2017-09-09 17:03:45

How to protect against value substitution in select?

Controller: View: View from all this renders like this:
$categories = Category::pluck('title', 'id');
{{ Form::select('category', $categories) }}

<select name = 'category'>
<option value = "1">Technologoies</option>
<option value = "2">Programming</option>
</select>

The user can take and replace value with any number, and it will end up in the post table, the category_id column as the number that the user entered and which, in principle, does not exist in the category table. How to deal with it? In Request, check the value, is there such an ID in the Category table?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
oh, 2017-09-09
well @AnneSmith

data is validated before being sent to the database

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question