Solved

Zend_Form_Element_MultiCheckbox default values? (part of Zend Framework)

Posted on 2010-08-18
1
1,675 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:
Richard Quadling 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

770 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