Cakephp 2.x form validation not working on multiple checkboxes

I am working on a form with cakephp 2.X

The form is working only now i need to add an extra required validation on multiple checkboxes

The Openmind Controller:

        if ($this->request->is('put') || $this->request->is('post'))
        {

            $this->Session->write('register', 1);

            $this->Openmind->create();

            if ($Openmind = $this->Openmind->save($this->request->data))
            {

                if (is_array($this->request->data['OpenmindInterest']))
                {
                    for ($i=0; $i<count($this->request->data['OpenmindInterest']['interest_id']); $i++)
                    {

                        $this->OpenmindInterest->create();
                        $this->OpenmindInterest->save(array(
                            'openmind_id' => $Openmind['Openmind']['openmind_id'],
                            'interest_id' => $this->request->data['OpenmindInterest']['interest_id'][$i]
                        ));

                    }
                }

                $this->Openmind->save($Openmind);

                $this->sendEmail($Openmind['Openmind']['openmind_id']);

                $this->redirect( array(
                    'controller' => 'openminds',
                    'action' => 'registered',

                ) );

            }

        }

I added the validation rule to my OpenmindInterest model, but the validation is not set when i post the form.

This is my OpenmindInterest Model:

    class OpenmindInterest extends AppModel {

    public $useTable = 'openmind_interests';
    public $primaryKey = 'openmind_interest_id';

    public $validate = array(

        'interest_id' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'Vul je voornaam in'
            )
        )
    );


    public $belongsTo = array(
        'Openmind' => array(
            'className' => 'Openmind',
            'foreignKey' => 'openmind_id'
        ),
        'Interest' => array(
            'className' => 'Interest',
            'foreignKey' => 'interest_id'
        )
    );

}

This is the output from $this->request->data
The interest_id array are the checkboxes:

array(
'Openmind' => array(
	'gender' => '',
	'firstname' => '',
	'middlename' => '',
	'lastname' => '',
	'city' => '',
	'emailaddress' => '',
	'emailaddress_check' => '',
	'education_id' => '',
	'current_education_custom' => '',
	'current_class' => '',
	'keep_informed' => '0',
),
'OpenmindInterest' => array(
	'interest_id' => array(
		(int) 0 => '1',
		(int) 1 => '2',
		(int) 2 => '3',
		(int) 3 => '4',
		(int) 4 => '5',
		(int) 5 => '6',
		(int) 6 => '7'
	)
)

)

Why doesn’t the $this->OpenmindInterest->save function starts the validation?

If i need to give more info, i would be happy to help ofcourse :slight_smile: