zend-form

Zend Framework - Set 'selected' value in select box dropdown list

I am adding a select element to a Zend_Form instance as follows: $user = $form->createElement('select','user')->setLabel('User: ')->setRequired(true); foreach($users as $u) { if($selected == $u->id) { $user->addMultiOption($u->id,$u->firstname.' '.$u->lastname); //*** some way of setting a selected opt...

Zend_Dojo_Form onSubmit

I have a contentPane with a remote form, I'm trying to get the form to submit, and stay within the pane, either displaying the form again on error or reporting success. I'm sure this is easy but I'm stumped, not the first time and not the last I'm sure. Store Form : class Services_Form_Store extends Zend_Dojo_Form { protected ...

Possible to add javascript to Zend_Form_Element_Radio?

Ultimately, I'd like my Zend Form to render this HTML: <p>Do you have any documents to upload?</p> <p>Yes <input type="radio" value="Yes" name="uploadChoice" onClick="showTable()">&nbsp;&nbsp;No <input type="radio" value="No" name="uploadChoice" onClick="hideTable()" checked></p> Here's what I have in my Zend_Form: //create radio bu...

How to change the layout of a form with Zend_Form decorators?

I'm totally confused about how decorators work. This is the html structure that I'm trying to achieve: <form id="" action="" method="post"> <fieldset><legend>Contact form</legend> <p> <label for="name">Name</label> <input type="text" name="name" id="name" size="30" /> </p> <p> <label for="email">Ema...

How can I protect users from cross-site request forgeries using the Zend Framework?

My program uses Zend Framework, and I wanted to protect users from CSRF using Zend_Form_Element_Hash. But It doesn't seem to work. For example, my code for Logout Form is $exithash = new Zend_Form_Element_Hash('hihacker', array('salt' => 'exitsalt')); $this->addElement($exithash); In my Auth plugin for Controller I do $e...

How to verify password field in zend form?

In my form, I'm trying to verify that the user fills in the same value both times (to make sure they didn't make a mistake). I think that's what Zend_Validate_Identical is for, but I'm not quite sure how to use it. Here's what I've got so far: $this->addElement('password', 'password', array( 'label' => 'Password:', 'required' ...

Zend Form, table decorators

Hello, I am having an incredibly difficult time to decorate a Zend form the way I need to. This is the HTML structure I am in need of: <table> <thead><tr><th>one</th><th>two</th><th>three</th><th>four</th></thead> <tbody> <tr> <td><input type='checkbox' id='something'/></td> <td><img src='src'/></td> <td><input type='text' id='some...

Zend_Form array notation and empty elements names

I'want to render: <input type="text" value="" name="foo[]" /> <input type="text" value="" name="bar[]" /> but Zend_Form_Element require a (string) name, so I need to do: $this->addElement('text', '1', array( 'belongsTo' => 'foo' )); $this->addElement('text', '2', array( 'belongsTo' => 'bar' )); but the output is: <input i...

Zend_Form set action - Can it work w/ Zend application built in subdirectory?

My application is being built in a subdirectory of my local server, that looks something like this: http://localhost/application/ The problem is that when I set the form action to "/form/save", the form routes to "localhost/form/save", which doesn't exist. If I set the form action to "/application/form/save", I get an error, becaus...

can zend_form be used with pagination?

Hi, I am not sure if this is the most sensible way of doing this but I thought I would ask anyway. I have a 'wizard' that I am developing for users to review data that is stored in the database. Each part of the wizard is a simple Zend_Form allowing the users to review and edit the data. However one element of the wizard needs to be a...

Dynamically add a Dojo-enabled Element in Zend

I'm writing a form using Zend_Dojo_Form. Everything goes fine, unless I dynamically insert elements into the form (using ajax, the user can add more elements by clicking a [+] button). I managed to insert my new Zend_Dojo_Form_Element_FilteringSelect into the page, but the element isn't dojo-enabled (no auto-completion, or tundra styli...

Zend_Form from ini, set multiOptions with string values

I'm trying to configure a form for Zend_Form using Zend_Config_Ini, and wish to set the options for a select element in the .ini file. This works fine for options with single string values, i.e. user.exampleform.elements.subject.options.multiOptions.example = "Example Label" However, I can't work out how to use a string for the value...

dynamicaly adding textboxes to zend_form

Hi, I hope that this is a quick question to answer. I am developing a form using Zend_Form, I have a number of Zend_Dojo_Form_Element_Textboxs to add to this form dynamically. These are added from rows in the database, e.g. $count = 0; //we now loop through the skill types and add them to the form. foreach($skillResult as $ski...

File Upload in Zend

Hello every body, i m using zend form & create its elements using the code below. // To create text box. $txt = $this->CreateElement('text', 'txtName'); $txt = $this->setLabel('First Name'); $elements[] = $element; it works fine & it is posted firm form as well. But when i used the same technique to show a browse button, like. // To ...

jquery autocomplete and datepicker compatability issue?

Hi, I have a form that is constructed using ZendX_JQuery_Form, the form contains 2 auto complete inputs and 4 datepickers. The datepickers all worked absolutely fine until I added in the autocomplete fields as well, the autocomplete fields (linking to a backend php action in zend framework) work fine as well but they seem to break the d...

The best way to render a Zend_Form with existing markup

Hello! I want to use Zend_Form because of its validation and filters etc. But the markup for forms is already done. Even worse, it isn't very standardized, so writing my custom decorators is not a solution. Is there a simple way to "apply" Zend_Form to existing very custom markup? I think it's a common problem. ...

How to test my forms in Zend Framework 1.8+?

So I've set up testing in my ZF 1.9.5 application thanks to this tutorial, I am able to test my controllers, now I want to create a test for a form. However, I'm having the problem that PHPUnit can't find my form. Fatal error: Class 'Default_Form_AccountProfile' not found I'm extending PHPUnit_Framework_TestCase instead of Zend_Test_...

How to disable a form element in a Zend Form?

I want to display a Zend Form with one of the elements shown as disabled. I'm setting the value so the user can see it, but I want to disable it so the user can't edit it. This may also involve some sort of css/javascript to ensure that it looks like, and is not editable by the user. This is my element: $this->addElement('text', 'us...

Phone Number Validator/Filter using jQuery or Zend Form?

I'm thinking about adding some validation/filtering to the phone number field of my Zend Framework application. Not sure if this is something I should do or not. I thought it might be helpful for users to have such a feature so I could enforce a particular display format. I'm not sure if the formatting of the phone number should be stor...

Get values from controller to form

Hi there, I'm using the PHP Zend Framework. How can I get the values from the controller sent by: $infoForm=array( // I get these values from a DB 'idCity' => $idCity , 'idRestaurant'=>$idRestaurant ); $form->populate($infoForm); i get the info in the Dojo_Form $city = new Zend_Dojo_Form_Element_FilteringSel...