zend-form

How to validate either Zend_Form_Element_File or Zend_Form_Element_Text are not empty.

≯℡__Kan透↙ 提交于 2019-12-08 06:17:20
问题 In my form, I want user to pick a file OR enter it's URL. One of two options. I know how to write a validator for either one of two Zend_Form_Element_Text elements, but since data from Zend_Form_Element_File is not in $_POST but in $_FILES I don't know where to begin - I can't get the data from Zend_Form_Element_File to be in a $context in isValid($value, $context = null) method for my custom validator. Any ideas? 回答1: A possible approach I can think of is to pass the information if the file

Zend_Form - multiple forms on same page

a 夏天 提交于 2019-12-08 05:48:50
问题 Having multiple forms in one page, when i submit one of them, how can i tell wich one was submitted? I thought about generating uniqe ids for each from, and saving them as hidden fields and to the user-session - while this is a solution, the problem with it is that there is no good place to remove old ids from the session. Any better ideas how to solve this problem? Thanks in advance! 回答1: First of all: have you considered sending the two forms to two different actions? That way you can

Zend Framework URL - How to pass a query string?

不想你离开。 提交于 2019-12-08 05:34:30
问题 I have this link: <a href="<?php echo $this->url(array('controller'=>'index','action'=>'form'),NULL,TRUE);?>"> Form </a> With this I get something like: http://foo.com/form I need to pass a param to the URL with this link. So that I can have something like this instead: http://foo.com/form?bar=1231 How can we accomplish this ? Thanks in advance. 回答1: The URL view helper is used to create links using the Routes setup with your application. If you aren't following the routes setup, then there

Edit individual radio buttons in zend form view script

扶醉桌前 提交于 2019-12-08 05:29:50
问题 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 options in one column then the next 5 in a second column. 回答1: I have the same issue. There is no nice way to do this that I have found (circa ZF 1.10.8) Matthew

On submit the form don't display its POST data

放肆的年华 提交于 2019-12-08 05:16:02
问题 I have a little experience with Zend Framework, but I like to fiddle with it until it works. But now I cannot resolve this problem. I have a form: <?php class Application_Form_Login extends Zend_Form { protected $notEmpty; public function init() { // Create NotEmpty validator $notEmpty = new Zend_Validate_NotEmpty(); // Configure validators for username element $notEmpty->setMessage('Gelieve dit veld in te vullen'); $this->setMethod('post'); // emailAddress $this->addElement('text',

Can't set custom validator messages in Zend_Form

為{幸葍}努か 提交于 2019-12-08 04:57:13
问题 I just can't figure it out how to set custom validator messages in Zend_Form object. Here is an example code. $this->addElement('password', 'password', array( 'label' => 'Password', 'decorators' => array('ViewHelper'), 'filters' => array('StringTrim'), 'validators' => array( array('Digits', false, array('messages' => array('notDigits' => 'Only digits are allowed here'))) ), 'required' => true )); When I try to validate the form entering invalid data a message saying "notDigits" appear. I

Difference between InputFilterAwareInterface and InputFilterProviderInterface in ZF2

邮差的信 提交于 2019-12-08 03:37:33
Can someone explain me the difference between both interfaces InputFilterAwareInterface and InputFilterProviderInterface? Both seem to serve to the same purpose, to get an InputFilter, but I know they cannot be the same... And when do they get called? Thanks edigu Both interfaces exist for different purposes. The InputFilterAwareInterface guarantees that implemented classes will have a setInputFilter() and getInputFilter() methods which accept and return an InputFilter instance when necessary. On the other hand, the InputFilterProviderInterface guarantees only that implemented classes will

Difference between InputFilterAwareInterface and InputFilterProviderInterface in ZF2

元气小坏坏 提交于 2019-12-08 03:12:03
问题 Can someone explain me the difference between both interfaces InputFilterAwareInterface and InputFilterProviderInterface? Both seem to serve to the same purpose, to get an InputFilter, but I know they cannot be the same... And when do they get called? Thanks 回答1: Both interfaces exist for different purposes. The InputFilterAwareInterface guarantees that implemented classes will have a setInputFilter() and getInputFilter() methods which accept and return an InputFilter instance when necessary.

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

孤街浪徒 提交于 2019-12-08 02:41:27
问题 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? 回答1: They are solely for structuring the output of your Zend Form elements in a definition list. Whether your form renders errors is controlled through the Error Decorator. See this series of articles by Matthew Weier O'Phinney: The simplest Zend Form Decorator How to layer

Zend Form Decorators Error in Table

大憨熊 提交于 2019-12-07 23:43:27
问题 I am using the next decorators for my input. I want to make this as table. $this->setDecorators(array('ViewHelper','Errors', array(array('data'=>'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row'=>'HtmlTag'),array('tag'=>'tr')) )); But after form validation Errors showing not in td. How can I do this? I want to make the next makeup: <table> <tr> <td>Lable</td> <td>Input</td> <td>Error</td> </tr> </table> 回答1: $this->setDecorators( array( 'ViewHelper',