zend-form

How do configure Zend_Form to use array notation?

 ̄綄美尐妖づ 提交于 2019-11-29 22:10:07
问题 I'm having difficulty configuring Zend_Form. I have a Zend_Form sub-class. The form has some required information and some additional information. I want the additional information to be accessible via an array. The submitted data will look something like this: $formData['required1'] $formData['required2'] $formData['addiotnalData']['aData1'] $formData['addiotnalData']['aData2'] I've Googled this and tried all the suggestions I've found (using subForms and setting the Zend_Form::setIsArray(

Password Confirmation in zend framework

北城余情 提交于 2019-11-29 21:32:44
问题 I add this class to library/My/Validate/PasswordConfirmation.php <?php require_once 'Zend/Validate/Abstract.php'; class My_Validate_PasswordConfirmation extends Zend_Validate_Abstract { const NOT_MATCH = 'notMatch'; protected $_messageTemplates = array( self::NOT_MATCH => 'Password confirmation does not match' ); public function isValid($value, $context = null) { $value = (string) $value; $this->_setValue($value); if (is_array($context)) { if (isset($context['password']) && ($value ==

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

北城以北 提交于 2019-11-29 19:58:58
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? For hidden field you need only one decorator - ViewHelper: $field = new Zend_Form_Element_Hidden('id'); $field->setDecorators(array(

In a Zend_Form, how to avoid Zend_Validate_Email from generating multiple errors?

大城市里の小女人 提交于 2019-11-29 18:30:56
问题 I am building a ZendFramework application which as a login form asking for an email address and password - it seemed to make sense to validate the email address before hitting the database with the login attempt, as an invalid email would never lead to a valid hit. Zend_Validate_EmailAddress seemed like the right way to go, but I am having an issue with it generating multiple errors (question at the bottom, after the code). My form currently has the following //WPMail_Form_Login::init()

ZF2/Doctrine2 - Fieldsets not validated, data is always valid

笑着哭i 提交于 2019-11-29 16:24:37
I've set up a structure using Abstract classes for Forms, Fieldsets and InputFilters. Forms and Fieldsets have Factories while InputFilters are created and set on the Fieldsets by the FieldsetFactory (uses the MutableCreationOptionsInterface to pass along options) The problem I have is that InputFilters are loaded for the Form, but are not used to validate the data. All input is accepted as valid. E.g. I have a Country Entity with a name property. The name of the Country must be at least 3 chars and max 255. When the name is "ab", it's found to be valid. Before someone asks : no error is

Zend Framework: Working with Form elements in array notation

…衆ロ難τιáo~ 提交于 2019-11-29 05:35:06
I would like to be able to add a hidden form field using array notation to my form. I can do this with HTML like this: <input type="hidden" name="contacts[]" value="123" /> <input type="hidden" name="contacts[]" value="456" /> When the form gets submitted, the $_POST array will contain the hidden element values grouped as an array: array( 'contacts' => array( 0 => '123' 1 => '456' ) ) I can add a hidden element to my form, and specify array notation like this: $form->addElement('hidden', 'contacts', array('isArray' => true)); Now if I populate that element with an array, I expect that it

Action View Helper in Zend - Work around?

送分小仙女□ 提交于 2019-11-29 03:57:54
I'm working on building up an interface that I want to function as a "tabbed browsing" sort of function. Each of these tabs has already been written as an action and the tabbed interface works fine as links to the individual tabs. I decided to try writing the "index" page for this controller - putting the content of all the tabs into hidden divs and swapping between them with jQuery, but once I started to use the action view helper - I ran into a lot of people saying that its bad practice. ( see this article ) Some of these actions build up forms - grab some data from the model, etc to display

Add class attribute to Form Errors

旧巷老猫 提交于 2019-11-29 02:45:46
问题 I´m developing an application using Zend Framework 2 and I use FormRow helper to render a label, the input and errors (if present) in a Form. //within the view echo $this->formRow($form->get('Name')); When a user submits the form without filling the required input text field FormRow render´s it with the following error message: <label> <span>Name: </span> <input class="input-error" type="text" value="" placeholder="Insert Name Here" name="Name"> </label> <ul> <li>Value is required and can't

zend form custom attribute in select option?

自闭症网瘾萝莉.ら 提交于 2019-11-29 02:34:11
问题 I want know how to add custom attribute for option in a select field of Zend form. PHP: $option_values = array("multiOptions" => array( "US" => "United States", "CA" => "Canada", )); $type=array('big','small'); $option= new Zend_Form_Element_Select('option', $option_values); HTML: <select> <option value='US' type='big'>United States</option> <option value='CA' type='small'>Canada</option> </select> How to add this type attribute in the option? 回答1: It is not possible using ZF's implementation

Zend_Framework Decorators Wrap Label and ViewHelper inside a div

依然范特西╮ 提交于 2019-11-28 20:37:17
问题 I am new to this, zend decoration malarchy, but i have two significant questions that i cant get my head around. Question one is followed by some example $decorate = array( array('ViewHelper'), array('Description'), array('Errors', array('class'=>'error')), array('Label', array('tag'=>'div', 'separator'=>' ')), array('HtmlTag', array('tag' => 'li', 'class'=>'element')), ); ... $name = new Zend_Form_Element_Text('title'); $name->setLabel('Title') ->setDescription("No --- way"); $name-