Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-08-2008, 10:13 AM
Junior Member
 
Join Date: May 2008
Posts: 1
Default Set a element of Zend_Form_Element_MultiCheckbox as "checked"

Hello!
In a project i'm extending the Zend_Form to create a form, in this form in need to use Zend_Form_Element_MultiCheckbox for listing a series of elements coming from a db query, but i also need to set any of this as checked (with the html attributer checked= "checked") how can do this?
Here below the code that i use to generate the component
PHP Code:
$group = new Zend_Form_Element_MultiCheckbox('groups');
        
$group->setLabel('Groups');
        
$groups = new Groups();
        
$groupsRows $groups->fetchAll();
        foreach (
$groupsRows as $groupsRow ){
            
            
$group->addMultiOption($groupsRow->id,$groupsRow->name);
        } 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-09-2008, 12:34 PM
Junior Member
 
Join Date: May 2008
Posts: 1
Default

$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();


ciao Marcello
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:19 AM.