views:

396

answers:

1

I have been looking for hours and I can't find any documentation anywhere as to how you set the default value of an element using Zend_Config_Ini as the initialisation to a Zend_Form.

I've seen the documentation for how you do it in normal PHP code...

$validators = array(
    'month' => array(
        'digits',
        'default' => '1'
    )
);
// no value for 'month' field
$data = array();
$input = new Zend_Filter_Input(null, $validators, $data);
echo $input->month; // echoes 1

But there's no documentation as to how you set it in an .ini file. I've tried everything (obviously not, but it seems so)!!

Does anyone know the "syntax"?

query.elements.rows.type = "text"
query.elements.rows.options.required = true
query.elements.rows.options.validators.rows.validator = "digits"
query.elements.rows.default = 0 # DOESN'T WORK!

If the "rows" value provided isn't of "digits" then I want it set to "0".

Thanks in advance!!

A: 
query.elements.rows.type = "text"
query.elements.rows.options.required = true
query.elements.rows.options.validators.rows.validator = "digits"
query.elements.rows.options.value = 0 # This works ;)

If the "rows" value provided isn't of "digits" then I want it set to "0".

This is not achievable by default options. Try the following code:

if( !$form->isValid( $_POST ) ) {
    $errorsMessages = $form->getMessages();
    if(isset($errorsMessages['rows']['notDigits'])){
        $form->getElement( 'rows' )->setValue( '0' ) ;
    }
}
St.Woland