With array('question','type','type'=>'array','allowEmpty'=>false), you can simply verify that you are receiving the exact array, but you do not know what is inside this array. To check the elements of an array, you should do something like:
<?php class TestForm extends CFormModel { public $ids; public function rules() { return [ ['ids', 'arrayOfInt', 'allowEmpty' => false], ]; } public function arrayOfInt($attributeName, $params) { $allowEmpty = false; if (isset($params['allowEmpty']) and is_bool($params['allowEmpty'])) { $allowEmpty = $params['allowEmpty']; } if (!is_array($this->$attributeName)) { $this->addError($attributeName, "$attributeName must be array."); } if (empty($this->$attributeName) and !$allowEmpty) { $this->addError($attributeName, "$attributeName cannot be empty array."); } foreach ($this->$attributeName as $key => $value) { if (!is_int($value)) { $this->addError($attributeName, "$attributeName contains invalid value: $value."); } } } }
source share