zend-form

How to use data from Zend_Db_Table in a Zend_Form

I have create a form class for editing deleting and add users to a database. If I want to edit a user how can I simply supply the information of the user to the form. I use a Zend_Db_Table to get the data from the database. This is the userForm class: class UsersForm extends Zend_Form { public function init () { $username...

Customizing Zend_Form

I am dealing with Zend_Form right now and am having a difficult time figuring out how to: 1. Use custom images for form buttons and, 2. Insert text and links in specific places (in my case I want to put a "forgot your password?" link before the submit button). I've read through the manual but am not seeing anything about this. Any direc...

Zend_Form: how to check 2 fields are identical

I have created a form to add a user to a database and make user available for login. Now I have two password fields (the second is for validation of the first). How can I add a validator for this kind of validation to zend_form? This is my code for the two password fields: $password = new Zend_Form_Element_Password('password', array(...

Zend Framework - Zend_Form Decorator Issue

I have a class that extends Zend_Form like this (simplified): class Core_Form extends Zend_Form { protected static $_elementDecorators = array( 'ViewHelper', 'Errors', array('Label'), array('HtmlTag', array('tag' => 'li')), ); public function loadDefaultDecorators() { $this->set...

Populating Selects from the Database using Zend_Form

What is the best way to populate a select element that is part of Zend_Form? I've used populate() to fill in various form element values but the select statements do not get populated. My solution, which works but I suspect is not ideal, is as follows: In the init() method of MyForm (which extends Zend_Form) I make a database call and...

Zend Framework: How do I set a custom validator on a form element?

I'm writing a custom validator that checks that at least one field has a value. I want to validate that either 'namefield' or 'idfield' has a value. One of them can be empty, or both can have a value, but at least one of them must have a value. $nameField = new Zend_Form_Element_Hidden('namefield'); $nameField->setValue($this->nameField...

Zend Framework: is there a way to access the element name from within a custom validator?

I'm writing a custom validator that will validate against multiple other form element values. In my form, I call my custom validator like this: $textFieldOne = new Zend_Form_Element_Text('textFieldOne'); $textFieldOne->setAllowEmpty(false) ->addValidator('OnlyOneHasValue', false, array(array('textFieldTwo', 'textFieldThree'...

Zend_Form - Array based elements?

Using Zend_Form, how would I create form elements like this: <input type="text" name="element[1]" value="" /> <input type="text" name="element[2]" value="" /> // etc... ...

Zend_Form radio element

Below is sample code to create a radio button element with Yes/No options in Zend_Form. Any ideas on how to set the required answer to Yes, so if No is selected, it'll fail validation? The code below will accept either Yes or No. $question= new Zend_Form_Element_Radio('question'); $question->setRequired(true) ->setLabel('Are you sur...

Zend_Form -> Nicely change setRequired() validate message

Say I create a text element like this: $firstName = new Zend_Form_Element_Text('firstName'); $firstName->setRequired(true); Whats the best way to change the default error message from: Value is empty, but a non-empty value is required to a custom message? I read somewhere that to replace the message, just use addValidator(......

Zend Framework: How do I remove the decorators on a Zend Form Hidden Element?

I'm trying to remove the default decorators on a hidden form element. By default, the hidden element is displayed like this: <dt>Hidden Element Label (if I had set one)</dt> <dd><input type="hidden" name="foobar" value="1" id="foobar"></dd> I don't want my hidden element to take up space on my page. I want to remove all the default de...

Zend_Form_Decorator - How to add attrib to Zend_Form_Element_Hidden ?

I have 2 requirements: 1) All hidden input elements should be affected without removing standard decorators. 2) This should happen WITHOUT having to specify it on a per-element basis. All I need is for a CSS class to be attached to the DT & DD tags IF the element type is Zend_Form_Element_Hidden. I've tried creating custom HtmlTag, DtD...

Zend_Form + DHTML content

Whats the best way to dynamically add NEW dhtml content to a form that's generated via Zend_Form. Example, say the form is created like so: class formUser extends Zend_Form { public function __construct( $options = null ) { parent::__construct( $options ); $page1 = new Zend_Form_Element_Text( 'page1' ); $pag...

Zend Form: How do I make it bend to my will?

I've read the manual many times, I've scoured the posts offered by Google on the subject, I have even bought a couple of books that deal with ZF. Now, why am I still confused? I can, using Zend_Form, make a form that validates and functions fine. What I cannot do it make a form that looks exactly like I want it to look with the error me...

Zend_Form_Element_Text Raising Error Prematurely

This is my code $firstname = new Zend_Form_Element_Text('firstname', array('id' => 'firstname')); $firstname->setLabel('Firstname') ->addError('Your firstname.') ->addFilter('StringTrim') ->addFilter('StripTags') ->addValidator('StringLength', false, array(1)) ->setRequired(true); $form->addElement($firstname); ...

Loading models in Zend_Form using Zend Framework

I'm trying to build a form using the Zend_Form component, but the number of elements varies. The information for each Zend_Form element is stored in a database (name, options, validators, filters, etc.). The application I'm working on consists of building surveys which contain a varying number of questions. Each question is associated w...

Handing dates in Zend_Form - changing to and from date formats

Hi, I'm working on a Zend Framework (v1.7) application that calls for a few forms that users need to enter dates on. The user is prompted to enter dates in the dd/mm/yyyy format, but the MySQL database wants the dates to be presented in yyyy-mm-dd format. Therefore, i'm having to do the following: Loading the form Grab the data fr...

Zend Form: Add a link to the right of a text field

I realize that I should be able to do this, but what can I say, I don't get it. I've even rtfm'ed until my eyes fried. I learn best by examples, not the deep explanations that Zend's docs give, or the typical "use decorators" response that this type of questions usually produce. What I need is markup like this: <dt> <label for="nam...

triggering invalid message with zend_dojo elements on post fail.

Hi, I am having a few issues with a Zend_Form that I have which uses Dojo elements to handle user validation. The scenario is when are user fills in the form the dojo elements ensure the formatting is correct. On post of the form if there is an error such as the email address already existing in the database, my code throw an excepti...

File Upload using zend framework 1.7.4

I am trying to upload file using zend frame work but have not been successful. I have read Akras tutorial, which was helpful but when i used those techniques in my project I was not able to get it to work. ...