-- Teemu Välimäki <[EMAIL PROTECTED]> wrote
(on Wednesday, 19 March 2008, 08:44 AM +0200):
> How do I set submit, text etc. value before rendering with Zend_Form 
> constructor array? I see methods such as setDefault and populate for it.

In most cases, you pass a 'value' option. The exceptions are
submit/reset/button types, and checkboxes; some examples are below:

    $form = new Zend_Form(array(
        'elements' => array(
            'save' => array('submit', array(
                'label' => 'Save',
            )),
            'optin' => array('checkbox', array(
                'label' => 'Do you choose to Opt In?',
                'checkedValue'   => 'yes',
                'uncheckedValue' => 'no',
                'value'          => 'yes',
            )),
            'name' => array('text', array(
                'label' => 'Your name:',
                'value' => '<type your name here>',
            ))
        ),
    ));

This shows the three types of functionality. With submit/reset/button
types, the label is used for two things: the value of the input, which
is what is used for the label of the button. With checkboxes, you may
want to specify what the checked and unchecked values are when
submitted. The checkedValue will be the 'value' attribute of the
rendered element; setting the value of the element to the checked value
will mark it as checked (any other value will mark it as unchecked, and
set the internal value to the unchecked value).

All other elements, such as the 'name' element above, will take the
value and use it for the rendered input.

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to