zend-form

Appending or Prepending HTML Tags to Zend Form Element

For the purposes of styling I have the need to put an opening <div> at the beginning of one element, and a closing </div> tag at the end of another. Looking over the docs for HtmlDecorator I can't seem to figure out how to get it right, or if this is even the right decorator to use. It seems wasteful to have to create my own decorator si...

Changing Zend_Form behavior to call JS function upon submit

Hello, I would like to change the default behavior of Zend_Form, so that whenever the submit button is clicked, form submission is prevented and an arbitrary JavaScript function is called. This would be done for all forms on the site, however the actual JS function to call may change from form to form. What would be the most proper way...

Display data in table on a subform

Hi all, I've got a question regarding sub forms. Currently I've got 2 sub forms and one parent form. On one of the sub forms I want to get data from the model and this needs to be displayed in a table, the first column needs to have a radio button as I want to know which row has been selected. But as a table isn't a form element how ca...

Zend <dt> <dd> decorators: what do I lose by removing them

This question is specific to Zend_Form. Zend_Form adds standard decorators such as <dd> <dt> <dl>. What do I lose if I were to remove them? Are they used by Zend_Form itself for error reporting or any other reason? ...

Zend form setRequired(true) or addValidator(NotEmpty)

Is there any real difference between the behavior or output of these 2. They look to me like they do the same thing. ->addValidator('NotEmpty') ->setRequired(true) ...

Zend_Form outputs without main HTML HEAD BODY tags

In my index/index action, I'm calling a form class that I created, and output the form in the index.phtml view like this <?php echo $this->form; But when I view the page source, all I'm getting is the form markup. I don't get any HTML HEAD BODY tags to make this a valid markup page. How do I add these to all my pages? I have layouts/...

Zend Framework: Post to different action then return to original action if fails validation AND keep form fields

This might sound like an odd scenario, but I've got two forms on one page. One is just posting back to itself. I made the second post to another action to keep the code cleaner. Maybe not the right choice... The problem I'm having now is that if that second form doesn't validate, I redirect back to the page with the form but I don't kno...

Zend changing validation error behavior: wrapping element in another tag

I've set a validator for the email so it can't be empty. This is the markup of the usual form that zend_form generates: <dt id="email-label"><label class="required" for="email">Email</label></dt> <dd id="email-element"> <input type="text" value="" id="email" name="email"> </dd> When validation fails, zend_form adds a new ul class...

Can custom decorator access parts of $content

In a custom decorator, I'm wrapping the element content with a div. This code creates a div around both the <dt> label and the <dd> element public function render($content) { return '<div class="test">' . $content . '</div>'; } Is there a way I can further access those 2 parts, the dd and dt. Such as maybe wrap the div arou...

Zend Framework: Populating DB data to a Zend Form dropdown element

Hi I have the following form: <?php class Application_Form_RegistrationForm extends Zend_Form{ public function init(){ $country = $this->createElement('select', 'country'); $country->setLabel('country: ') ->setRequired(true); $email = $this->createElement('text', 'email_address'); ...

zend_form: should I use one right in the layout

I usually instantiate my forms in an action and that's where I process them when they're submitted. I then pass them on to the view and output them there as usual. This form (a search box) is different because it's not part of a single page. It has to be visible everywhere. I've made it part of the template layout.phtml and instantiated...

Zend_form: what's the added "enctype" for?

Zend adds an enctype to all forms. What's that good for? and how can I remove it? <form action="" method="post" enctype="application/x-www-form-urlencoded" id="myform"> </form> ...

Confused about StripTags filter

I'm a little confused about the StripTags filter as used in Zend. I think it's meant to strip tags that could result in XSS. So shouldn't that mean it should be used when outputting data in the views? I've seen it being used with form inputs ->addFilter('StripTags') Should it be used with both input in the forms and output in the vie...

Zend_Form not displaying data

Here is my code: <?php class IndexController extends Zend_Controller_Action { public function indexAction() { $this->_forward('search'); } public function searchAction() { if($this->getRequest()->isGet()) { $form = $this->getForm(); $value = $form->getValue('search...

Zend_Form cross validation

Hi I'm working on a system and i have a form where i need to do cross validations. By cross validation i mean : if someone is from the united states the system must be able to check if the state that have been selected is a valid united states state and not a canadian province. Ideally, the error output message should be beside the faut...

Edit individual radio buttons in zend form view script

I have a zend form which is using a view script. I want to get access to the individual radio button items but I'm not sure how to do so. Right now, I just print them all out using: echo $this->element->getElement('myRadio'); That prints them all out vertically. I need a little more control. I need to be able to print the first 5 opti...

Zend Framework Nested Checkboxes

I would like to create a Zend_Form with nested checkboxes. I'm sure that it's possible, but I don't remember how to do it. This is what it would look like: [x] Top level checkbox 1 [ ] Sub level 1 [x] Sub level 2 [ ] Top level 2 [ ] Sub level 1 [ ] Sub level 2 How would I achieve this result? ...

Where does Zend_Form fit in the Model View Controller paradigma

The Zend Framework is mainly meant for MVC use. One of the very usefull components is Zend_Form. I have a bit trouble finding the place of Zend_Form. Is it part of the view, model, or controller and which responsibilities should I give it. The thing is, Zend_Form does two things: decorate and render the form and validate it. The first ...

Problem with zend validate on zend form element

Hi all, I used to have this form element to validate an email and display an error message if the format was invalid: $email_users = new Zend_Form_Element_Text('email_users'); $email_users->setLabel('Email:') ->setRequired(false) ->addFilter('StripTags') ->addFilter(...

How to test a custom Zend_Form with PHPUnit?

Does anyone have an example of how to test a custom Zend_Form that extend from that class with PHPUnit?? I may need to test the construct and the init... where i'm adding elements to the My_Custom_Zend_Form. ...