Hello guys,
I made my first Zend_dojo_form and I have 3 questions so far :)
I've attached file with my signupController.php because its to long to be posted here.
signupController.php.txtIts .txt but you can see whats inside.
I dont know how to do next things:
1. All fields in my form are required. But if you hit Submit button, all validation are some kind a avoided and i am redirected to my form action (signup/process). How to prevent form to do this?
My Code:
$footer= new Zend_Dojo_Form_SubForm();
$footer->setAttribs(array('name' => 'footerData','legend' => 'Submit','style' => 'clear:both'));
$footer->addElement('SubmitButton', 'submit', array(
'label' => 'Submit!'
));
$form = $form ->addSubForm($personalData, 'personalData')
->addSubForm($agreements,'agreements')
->addSubForm($footer,'footerData');
2. I also have a 3 checkbox. All 3 must be checked to procced. But form procced no matter what.
My code:
$agreements= new Zend_Dojo_Form_SubForm();
$agreements->setAttribs(array('name' => 'agreements','legend' => 'Submit','class' => 'agreements'));
$agreements ->addElement('checkbox','ages',array('required' =>true,'checked'=>true,'style'=>'float:left' ,'label'=>'I\'m Over 18 years old','invalidMessage' => 'You must validate that you are over 18',))
->addElement('checkbox','promotions',array('required' =>true,'checked'=>true,'style'=>'float:left' ,'label'=>'I agree NOT to send any email promotions promoting this web site','invalidMessage' => 'You must validate that you are over 18',))
->addElement('checkbox','terms',array('required' =>true,'checked'=>true,'style'=>'float:left' ,'label'=>'I agree to the Terms & Conditions','invalidMessage' => 'You must validate that you are over 18',));
3. Is there any way to validate a field if i need that this field have a valid URL address?
My code:
$personalData->addElement (
'validationTextBox',
'url',
array (
'label' => 'Main Site URL:',
'lowercase' => 'true',
'maxlength' => 40,
'value'=>'
http://',
'required' => true,
'invalidMessage' => 'Please enter your web site URL.',
'filters' => array (
'StringTrim',
'StringToLower' ),
'validators' => array (
'NotEmpty',) ) )
4. Is it possible to validate Email address with Zend_Dojo_Form?
My code is like this:
$personalData->addElement(
'validationTextBox',
'email',
array(
'required' => true ,
'label' => 'Email address' ,
'invalidMessage' => 'Please provide valid Email address.',
'filters' => array('StringTrim',
'StringToLower') ,
'validators' => array('NotEmpty',
array('StringLength', true, array (6, 20 ) ),
array('EmailAddress' , true, array())))
)
This aint work :)
Can someone help me on this please?
Thanks Vladimir