arip
(Arips4)
1
how to make validation scenario to double scenario
because while I make double scenario one of scenario couldn’t detected
the code
controller
$_POST['TbContact']['iscompany']==TRUE?$modelcontact->setScenario('iscompany'):'';
$_POST['TbContact']['isemployee']==TRUE?$modelcontact->setScenario('isemployee'):'';
model
array('businessentityid, company', 'required', 'on'=>'iscompany'),
array('govermentidnumber', 'required', 'on'=>'isemployee'),
acmakhoa
(Acmakhoa)
2
Can you check exist of the “$_POST[‘TbContact’][‘isemployee’]” or “$_POST[‘TbContact’][‘isemployee’]”?
madand
(Dev Madand)
3
Hi,
I think that most convenient way to do it is to add one more scenario to model like this:
controller code part:
...
$isCompany = (bool)$_POST['TbContact']['iscompany'];
$isEmployee = (bool)$_POST['TbContact']['isemployee'];
if ($isCompany && $isEmployee) {
$modelcontact->setScenario('iscompanyemployee');
}
elseif ($isCompany) {
$modelcontact->setScenario('iscompany');
}
elseif ($isEmployee) {
$modelcontact->setScenario('isemployee');
}
...
model code part:
...
array('businessentityid, company', 'required', 'on'=>'iscompany'),
array('govermentidnumber', 'required', 'on'=>'isemployee'),
array('businessentityid, company, govermentidnumber', 'required', 'on'=>'iscompanyemployee'),
...