zend-form

Zend Form SetAction Using Named Routes

倾然丶 夕夏残阳落幕 提交于 2019-12-18 13:14:34
问题 I have a form that I am trying to set the action for. I want to declare the action inside my form file (which extends Zend_Form) instead of in a controller or view, using a route I have created in my bootstrap. Usually when I want to use a route I do something like $this->url(array(), 'route-name'); in the view, or $this->_helper->url(array(), 'route-name'); in the controller. How do I call a route from within Zend_Form? edit: I have given up trying to load a route into zend_form. Perhaps in

How to use Zend Framework Form Hash (token) with AJAX

人走茶凉 提交于 2019-12-18 11:07:30
问题 I have included Zend_Form_Element_Hash into a form multiplecheckbox form. I have jQuery set to fire off an AJAX request when a checkbox is clicked, I pass the token with this AJAX request. The first AJAX request works great, but the subsequent ones fail. I suspect it may be once the token has been validated it is then removed from the session (hop = 1). What would be your plan of attack for securing a form with Zend Framework Hash yet using AJAX to complete some of these requests? 回答1: I

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

六眼飞鱼酱① 提交于 2019-12-18 10:03:10
问题 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 decorators so all I'm left with is the input tag. <input type="hidden" name="foobar" value="1" id="foobar"> How can I achieve this? 回答1: For hidden field you need

Zend Framework 2 - Form Element Decorators

会有一股神秘感。 提交于 2019-12-17 22:37:08
问题 I want to force the Zend form into Twitter Bootstrap style. I currently iterate through the form fields and write the form info into my bootstrap div construction. I saw in Zend Framework 1(!) that there is a way to do this within a decorator. But for some reason the doc for version 2 doesn't cover this point... I'd like to do something like this: protected $_format = '<label for="%s">%s</label>' . '<input id="%s" name="%s" type="text" value="%s"/>'; public function render($content) {

Zend Framework forms, decorators and validation: should I go back to plain HTML?

情到浓时终转凉″ 提交于 2019-12-17 17:26:58
问题 I am currently working on a pretty large application which contains a lot of forms. Up to this moment, I have always been writing my forms by hand and writing my own validation logic, but I have decided it was about time I started using Zend_Form and it's built-in validation routines. However, I keep stumbling upon more and more problems concerning the (lack of) flexibility caused Zend_Form_Decorator. Simple tasks like adding an extra button to a single input-element become incredibly

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

不问归期 提交于 2019-12-17 16:15:43
问题 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 option? selected="selected" } else $user->addMultiOption($u->id,$u->firstname.' '.$u->lastname); } I have been searching the docs but cannot find a simple way of pre-setting an option of the select

Zend Multiselect Element is posting only one selected values

陌路散爱 提交于 2019-12-14 02:33:45
问题 I am creating multiple select element like this and it is showed successfully on form: $element = new Zend_Form_Element_Multiselect('clinics'); $element->setLabel("Clinics"); $element->setAttrib( 'style','width: 240px' ); $element->setMultiOptions( array( '1'=>'clinic1', '2'=>'clinic2' ) ); After rendering above element it shows the following html in html source: <select name="clinics[]" id="clinics" multiple="multiple" style="width: 240px" size="5" class="required" tabindex="41"> <option

How get value selected using Zend_Form_Element_Select

我的未来我决定 提交于 2019-12-14 01:57:41
问题 I have the following code in a Zend form, creating a drop-down list fed from a database: // ... previously create the array $list and fill it from database $element = new Zend_Form_Element_Select('name'); $element->setLabel('List name') ->addMultiOptions($list); $this->addElement($element, 'list_name', array( 'required' => true, )); Question: how can I get the value after posting the form? With the above code, $post['name'] returns the index of the selected item. A detail: the html generated

form not binding post values to entity

大憨熊 提交于 2019-12-14 01:36:05
问题 I have a doctrine entity, a form and 2 fieldsets. When i populate the entity with values the values get hydrated into the form as expected. When i try to create a entity from form data it stays empty.. i must be forgetting something but just cant find it, i have several other forms without fieldsets and they work as expected. any ideas? posted my code below Entity: class User { /** * @var int * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /**

Apache Virtual Host Setup on Centos for Zend Framework 3

风流意气都作罢 提交于 2019-12-13 20:39:50
问题 I am newbie to zf3 and have extracted the ZF3 Skeleton Application from GitHub into location /var/www/html/zf2-tutorial and had installed successfully to get the zf3 home page from URL https://xxx.xxx.xx.xx/zf2-tutorial/public While going through the tutorial i found i have to set up a virtual host to access the site like zf2-tutorial.localhost so i followed the steps and making a zf2-tutorial.conf file under /etc/httpd/conf.d folder . zf2-tutorial.conf <VirtualHost *:80> ServerName https:/