I have a registration page and within this registration page the user will be required to fill in some interest, the interests values is called from a model with the name interest.php, all values are pulling through and saves as expected.
The relationship to the user model is
var $hasAndBelongsToMany = array(
'Interest' => array(
'className' => 'Interest',
'joinTable' => 'users_interests',
'foreignKey' => 'user_id',
'associationForeignKey' => 'interest_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
Whenever I add a validation rule in interest.php the little required star appears next to the checkboxes but it is not validating at all
<label for="InterestInterestId">Interests</label>
<input type="hidden" value="" name="data[Interest][interest_id]">
<div class="checkbox">
<input id="InterestInterestId8" type="checkbox" value="8" name="data[Interest][interest_id][]">
<label for="InterestInterestId8">Interest 1</label>
</div>
<div class="checkbox">
<input id="InterestInterestId1" type="checkbox" value="1" name="data[Interest][interest_id][]">
<label for="InterestInterestId1">Interest2</label>
</div>
in my view I call the multiple checkboxes like this
echo $form->input('Interest.interest_id', array('label' => __l('Interests'), 'multiple' => 'checkbox'));
This is my validation rule in interest.php
$this->validate = array(
'interest_id' => array(
'rule' => array(
'equalTo',
'1'
) ,
'message' => __l('Please select some interests')
)
);
Am I doing something wrong here, or missing something, any help will be appreciated!!!!