This is quite strange, I have a text input in a registration form and when I am setting the $validate array in the model, I am getting a trim() error - Warning (2): trim() expects parameter 1 to be string, array given [CORE\Cake\View\Helper.php, line 754]
Form input
<?=$this->Form->input("lastname", array("label" => array("text" => "Last name *"), "class" => "required", "div" => array("class" => array("input text last")))); ?>
Model validate array
public $validate = array(
'lastname' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'Last name is required'
)
)
);
It seems that when I am doing a validation rule for that field, the div styling array - "div" => array("class" => array("input text last")) is causing the error. I added the following code to the Helper.php file as a workaround:
if(is_array($options["class"])) {
$options["class"] = $options["class"][0];
}
but I would like to know why it is causing this error.