Solved

Zend_Form_Element_MultiCheckbox default values? (part of Zend Framework)

Posted on 2010-08-18
1
1,652 Views
Last Modified: 2013-11-10
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
Comment
Question by:davidsperling
1 Comment
 
LVL 40

Accepted Solution

by:
RQuadling earned 500 total points
ID: 33485455
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now