I have a simple form with a couple select inputs. One of which is a gender selections.
The input is generated like so:
echo $this->Form->input('gender_id', array(
'options' => array(
1 => 'Male',
2 => 'Female'
)
));
How can I ensure that only the given selects can be submit, so that a 3 or something can not be submitted?
I am using the Security component and it seems to protect against field name tampering but not value tampering.
Doing a simple comparison would not be practical for larger select lists like a State select. Also I’m trying to avoid doing extra queries to validate ids.
Require values to be in a specified list for your Model’s validation: