views:

33

answers:

1

hi everyone,

I need to make the following html using Zend form and form decorators...

<ul>
        <li id="containeruser1">
                <label for="user1"><input type="checkbox" class="textbox"  value="1" id="user1" name="users[]">User One</label>
        </li>
        <li id="containeruser2">
                <label for="user2"><input type="checkbox" class="textbox"  value="2" id="user2" name="users[]">User Two</label>
        </li>
        <li id="containeruser3">
                <label for="user3"><input type="checkbox" class="textbox"  value="3" id="user3" name="users[]">User Three</label>
        </li>
        <li id="containeruser4">
                <label for="user4"><input type="checkbox" class="textbox"  value="4" id="user4" name="users[]">User Four</label>
        </li>
</ul>

The php code i use is ....

 $userelement = new Zend_Form_Element_MultiCheckbox ( 'users' );
                    $userelement-> setRequired(true)
                    ->addDecorator("<li>")
                    ->addMultiOptions ( array ('1' => 'User One', '2' => 'User Two', '3' => 'User Three', '4' => 'User Four' ) )
                    ->setSeparator ( '</li><li>' )->addValidator('NotEmpty', true)
                    ->addErrorMessage('Please select at

least one user');
                $userelement->class = 'textbox';

The output is not exactly wht i want.... Each li tag needs to have a unique id so tht i can use some js to do some client side validations and modifications...... Im beginning to use Zend_form and the decorators are a bit confusing ......Please do help...

A: 

Consider using JS to locate the container. This way you don't have to change the decorators.
jQuery example

// example 1
$('#user1').parent().parent().css('color', 'green');

// example 2
$('#user1').parents('li').css('color', 'green');
michal kralik