开发者

Prevent empty field to be checked when selected parameter is empty

开发者 https://www.devze.com 2023-04-04 14:18 出处:网络
I have this line of code: echo $form->input(\'type\', array(\'label\' => \'Phase\', \'type\' => \'select\', \'multiple\' => \'checkbox\', \'options\' => $types, \'selected\' => $ins

I have this line of code:

echo $form->input('type', array('label' => 'Phase', 'type' => 'select', 'multiple' => 'checkbox', 'options' => $types, 'selected' => $inst_type, 'empty' => 'All'));

Now when 'selected' param is emp开发者_如何学Pythonty the checkbox created by the 'empty' param is checked. How can I prevent this?

Thanks in advance


you should not use "selected". simply use $this->data to prefill the form data - and only if $inst_type is not empty

so in the controller in the else block of !empty($this->data):

$this->data['Model']['field'] = $inst_type
0

精彩评论

暂无评论...
验证码 换一张
取 消