Solved

Zend_Form_Element_MultiCheckbox default values? (part of Zend Framework)

Posted on 2010-08-18
1
1,699 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why is my $_POST not going to results page 10 61
Delete image(s) associated with record(s) 16 44
Do not understand error message 3 44
history of pages 7 46
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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 …

742 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