0

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!!

1 Answer 1

1
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' ) ;
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.