In a similar vein to a previous question of mine
I need to validate a group of select inputs for order of voting preference. This time I've had to change it slightly.
The options to a user would be something like:
Choose in order of preference
1: [select with options]
2: [select with options]
3: [select with options]
The hash that this would produce could be something like:
["1" => "option-3", "2" => "option-1", "3" => "0"]
Where the 0 is a choice of no preference.
I have two questions:
How do I validate for the unique presence of the options selected - so there can't be multiple "option-2", but there can be multiple "0"'s (no preference)?
How would I validate to make sure that if someone selects 0 for the second select, they can't have an option in the third select (so with data like: ["1" => "option-3", "2" => "0", "3" => "option-1"])?
I've been trying all kinds of array manipulation but can't quite work it out.