zend-form

How to add a specific class to an input which has generated a form error?

I want to add a specific class to an input if an error is genereted by the input. For example, if input is empty and has required validator it shouls look like this: <dd id="login-element"> <input type="text" name="login" id="login" value="" class="input-text error" /> <ul class="errors"> <li>Value is required and can't...

Zend Framework: isValid() clears values from disabled form fields!

When you submit a form, disabled form fields are not submitted in the request. So if your form has a disabled form field, it makes working with Zend_Form::isValid() a little frustrating. $form->populate($originalData); $form->my_text_field->disabled = 'disabled'; if (!$form->isValid($_POST)) { //form is not valid //since my_tex...

is it possible to create subform and displaygroup without fieldset on zend forms?

is it possible to create subform and displaygroup without fieldset on zend forms? ...

Zend Date -- day difference

Hi All, I have the below line of codes $day1 = new Zend_Date('2010-03-01', 'YYYY-mm-dd'); $day2 = new Zend_Date('2010-03-05', 'YYYY-mm-dd'); $dateDiff = $day2->getDate()->get(Zend_Date::TIMESTAMP) - $day1->getDate()->get(Zend_Date::TIMESTAMP); $days = floor((($dateDiff / 60) / 60) / 24); return $days; this will return 4 But if ga...

Zend_Form - The mimetype of file 'foto.jpg' could not be detected

I have a Zend_Form with file element like this: ->addElement('file', 'image', array( 'required' => false, 'label' => 'Venue Image', 'validators' => array( array('IsImage', false), array('Size', false, '2097152'), array('Upload', false), ), )) And when I'm using lo...

How can I customise Zend_Form regex error messages?

I have the following code: $postcode = $form->createElement('text', 'postcode'); $postcode->setLabel('Post code:'); $postcode->addValidator('regex', false, array('/^[a-z]{1,3}[0-9]{1,3} ?[0-9]{1,3}[a-z]{1,3}$/i')); $postcode->addFilters(array('StringToUpper')); $postcode->setRequired(true); It creates an in...

Zend form whitespace validation

Hi all i have below code $name = new Zend_Form_Element_Text('name'); $validator = new Zend_Validate_Db_NoRecordExists('clients', 'name'); $validator->setMessage('A record already exists'); $name->addValidator($validator); $name->setLabel('Name'); $name->setRequired(); $name->setDecorators($decorator->elementDecorators); if i enter ab...

XSD for Zend Forms config XML

Does such scheme exist? If yes, where can I find it? ...

Add some html to Zend Forms

Hello everyone, Im looking for a simple bit of code that will let me add the following html into my zend form: <div id="wmd-button-bar" class="wmd-panel"></div> Thats it, it needs to be above my 'method' element in the form but thats it. For such a simple action I cant find any methods that don't involve me learning rocket science (i....

Zend Framework, Zend_Form_Element how to set custom name?

Hello, I have form, where some fields are looks like rows, so I can add/delete them using JS. For example: Field with ID=1 (existing row) <input id="id[1]" type="text" name="id[1]" value="1" /> <input id="name[1]" type="text" name="name[1]" value="100" /> Field with ID=2 (existing row) <input id="name[2]" type="text" name="name[2]...

how to populate a value in some element using zend_form

i have some fields in my database table,and a field with phone name , i save value to this filed like this 111-222-5555 now i want to read all of my fields , and populate to my form , i like populate phone filed to 3 elements(as text element) when i try this code $id = $this->_request->getParam ( 'id' ); $values = $cutomModel->findC...

Zend_Form Multiple dropdown as one value

Hello, For my zend form I would like a month drop down and a year drop down. I would like them to appear next to each other. Its okay for them to be separate elements in the zend_form and combine and check them in the controller, but for the design I would like them to sit right next to each other. I could accomplish this by setting n...

how to add special class for labels and errors on zend form elements?

hello how we could add a special class for labels and errors for a zend-form-element for example html output code before add classes <dt id="username-label"><label for="username" class="required">user name:</label></dt> <dd id="username-element"> <input type="text" name="username" id="username" value="" class="input" /> <ul class="err...

Zend form and dynamic file upload

Hello there i'm trying to create a form with Zend_Form that will enable my user to upload a unlited number of files to my site, witch is done by javascript. Something like <script type="text/javascript"> $(document).ready(function(){ var image_uploade_i = 0; $('#upload_more').click(function() { image_uploade_i++; ...

How do I write a custom validator for a zend form element with customized error messages?

I have a question field with a list of allowed characters : A-Z,0-9,colon (:), question mark (?), comma(,), hyphen(-), apostrophe ('). I have the regex which works fine, in the fashion : $question->addValidator('regex', true, array(<regular expresstion>)) The default error message is something like ''' does not match against pattern ...

php if clause inside foreach not retrieving data correctly

Here's my issue: In my controller, I want to grab user input from a form. I then parse the input, and compare it to database values to ensure I'm grabbing the correct input. I simply want to match the user's answers to the question, grab the user ID, the question ID, and then determine if the answer applies to a multiple choice or checkb...

Passing variables to a Custom Zend Form Element

Hi, I'm trying to create a custom form element which extends Zend_Form_Element_Text with a validator (so I don't have to keep setting up the validator when I use certain elements). Anyway, I'm having trouble passing $maxChars variable to it when I instantiate it in my Main form. I've provided my shortened code below This is my custom e...

How can I append a description to a Zend_Form_Element?

I have the following Zend_Form_Element: $imginstructions = "Some description"; $img = $this->createElement('select','img'); $img->setAttrib('class', 'image-select'); $imgdecorator = $img->getDecorator('Description'); $imgdecorator->setOption('escape', false); $img->setLabel('Image:') ->setRequired(true) ...

valitade zend framework's output

I use xhtml1-strict.dtd and validator.w3.org not validate Zend Forms. Tell me how you can validate Zend's html use $view->doctype('XHTML1_STRICT');, but is work only for FormText View Helper :/ example Zend output: <input type=""> I need: <input type="" /> ...

How can I add a plugin to the registry while using a Zend_Form?

I have a zend form that I'm initializing as follows: $form = new Form_XYZ(); I have a display group in that form, which I'm calling like this: $form->addDisplayGroup($generalSettingsGroup, 'general', array( 'legend' => 'General', ...