I came across the same problem, but now - after 3 years - with CakePHP 2.3 .
Be clear; Grouphas and belongs User. I had this form:
echo $this->Form->input('name');
echo $this->Form->input('User');
With the validation rule, as in user448164, answer:
public $validate = array(
'User' => array(
'rule' => array('multiple', array('min' => 1)),
'message' => 'Please select one or more users'
)
);
, , Googling , , . , :
echo $this->Form->input('name');
echo $this->Form->input('Group.User');
, , , .
, - .
CakePHP 2.4.x(, 2.3.x)
, CakePHP 2.3.x. . , , CakePHP 2.4.x, .
, :
$data = array(
'User' => array(
'Client' => array(8)
),
);
$this->User->create();
$this->User->saveAll($data);
: , "" , . , "", deep. :
$data = array(
'User' => array(
'Client' => array(8)
),
);
$this->User->create();
$this->User->saveAll($data, array('deep' => true));
! . :)
(2014/03/06)
, hasMany habtm. , . .
, Group.User User . User.