# Cakephp 2.x form validation not working on multiple checkboxes

**URL:** <https://discourse.cakephp.org/t/cakephp-2-x-form-validation-not-working-on-multiple-checkboxes/1677>\
**Category:** Need Help\
**Created:** [December 6, 2016, 2:03pm UTC](https://discourse.cakephp.org/t/cakephp-2-x-form-validation-not-working-on-multiple-checkboxes/1677 "2016-12-06T14:03:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![robin2609](https://avatars.discourse-cdn.com/v4/letter/r/b5a626/32.png) [@robin2609](https://discourse.cakephp.org/u/robin2609)\
**Post date:** [December 6, 2016, 2:03pm UTC](https://discourse.cakephp.org/t/cakephp-2-x-form-validation-not-working-on-multiple-checkboxes/1677/1 "2016-12-06T14:03:07Z")

</div>

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 🙂
