[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1777
  • Last Modified:

Zend_Form_Element_MultiCheckbox default values? (part of Zend Framework)

How to set which checkboxes that are checked by default?

You can use this as a starting point:
http://framework.zend.com/manual/en/zend.form.advanced.html 




0
davidsperling
Asked:
davidsperling
1 Solution
 
Richard QuadlingSenior Software DeverloperCommented:
From http://www.zfforums.com/zend-framework-components-13/model-view-controller-mvc-21/set-element-zend_form_element_multicheckbox-checked-1027.html

and

http://framework.zend.com/apidoc/core/Zend_Form/Element/Zend_Form_Element_MultiCheckbox.html#sec-methods


$form = new Zend_Form(); 
$group = new Zend_Form_Element_MultiCheckbox('groups');
$group->addMultiOption(1,'A');
$group->addMultiOption(2,'B');
$group->addMultiOption(3,'C');

// check item 1
$group->setValue(1);

// check items 1 and 3
$group->setValue(array(1,3));

// check all items
$group->setValue(true);


$form->addElement($group); 

echo $form->render();

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now