Questions tagged [zend-form2]

Zend Form2 is a class provided by the Zend Framework 2, an open source PHP >5.3 object oriented framework. The class assists in creating, rendering, and processing HTML forms.

82 questions
67
votes
2 answers

Zend Framework 2 Doctrine 2 one-to-many checkbox hydration

I have a ManyToMany that I broke into OneToMany and ManyToOne relationship. I want to build a form that has checkboxes instead of collection, and I am using the 'DoctrineObject' hydrator, but it does not work and I don't know what is going wrong. I…
Mohammad ZeinEddin
  • 1,608
  • 14
  • 17
24
votes
4 answers

How to add attributes to a label generated with Zend/Form in Zend framework 2

I'm adding forms to my page using Zend/Form. I'm adding elements by defining them as follows: $this->add(array( 'name' => 'value', 'attributes' => array( 'type' => 'text', 'id' =>…
El Dorado
  • 313
  • 1
  • 2
  • 14
24
votes
1 answer

Using dgrid in form collections in a Zend Framework 2 application

For our new project, we have started using Zend Framework 2 and Dojo 1.8. ZF2 has a completely rewritten form module, which now features the new CollectionElement for one-to-many relationships. Regarding UI I find, that dgrid fits best for such…
Ivaylo
  • 291
  • 1
  • 7
8
votes
4 answers

How to translate form labels in Zend Framework 2?

I'm not getting it!.. Can please someone explain, how to translate form labels? A simple example would be great. Thank you in advance! class Search\Form\CourseSearchForm ... class CourseSearchForm extends Form { ... public function…
automatix
  • 14,018
  • 26
  • 105
  • 230
6
votes
0 answers

How to make a Field injected multiple times to the Form unique in ZF2?

I have a pretty complex form with several nested Fieldsets and Collections. Some parts of the form are constant, other parts are variable: BasicSettings EndpointBasicSource (constant part) EndpointBasicTarget (constant…
6
votes
2 answers

How to implement a form preview page in Zend Framework 2?

In my current ZF2 project I have a complex Form with multiple levels of nested Fieldsets, that reflect the structure of objects to be saved in the background. Currently the data is sent directly to the Controller and gets saved to the database, if…
automatix
  • 14,018
  • 26
  • 105
  • 230
5
votes
3 answers

ZF2 An Invalid Factory Was Registered

I've the following classes and my module config in ZF2 application and it is giving the below error: While attempting to create applicationformuserform(alias: Application\Form \UserForm) an invalid factory was registered for this instance…
Manish Jangir
  • 5,329
  • 4
  • 42
  • 75
5
votes
1 answer

Filters and validators are added twice

I wrote about it on zf2 github and no one answered yet. But maybe it's not a bug and I'm doing something wrong. Here is my code: Fieldset class TestFieldset extends Fieldset implements InputFilterProviderInterface { public function…
Adrian Nowicki
  • 703
  • 6
  • 11
5
votes
1 answer

Loop through Form Elements in the order they were added

Zend Form 2 structures all Elements in Fieldsets. (Zend\Form\Form extends Fieldset - Form::add calls parent::add ) If i just add Elements to the Form i can get them via $form->getElements() if i use a fieldset i can get them…
Rufinus
  • 29,200
  • 6
  • 68
  • 84
4
votes
2 answers

How to make custom Radio-Button labels in ZF2 forms?

I have a form with Radio-button: $this->add([ 'name' => 'time', 'options' => [ 'value_options' => [ '0' => '9:00 - 12:00', '1' => '12:00 - 16:00', '2' => '16:00 - 19:00', ], …
Gennadiy Litvinyuk
  • 1,536
  • 12
  • 21
4
votes
2 answers

Dependency management in Zend Framework 2 MVC applications

As the ServiceLocatorAwareInterface will likely be removed from the AbstractController in ZF3, dependencies should instead be passed via the constructor or via setter methods. With this in mind, consider the use case of a user or site controller…
4
votes
3 answers

Select Element Validation

I have a Select element in my form like this: $this->add(array( 'name' => 'cat_id', 'type' => 'Zend\Form\Element\Select', 'options' => array( 'label' => 'Categoria', 'empty_option' => '', 'value_options' =>…
Vinicius Garcia
  • 1,740
  • 4
  • 30
  • 54
3
votes
0 answers

How to bind elements of a MultiCheckbox to an Object in ZF2?

I'm using nested Zend\Form\Fieldsets and Zend\Form\Collections, that provide an extremely comfortable way to map complex object structures to the form, in order to get a complete object (ready to be saved) from the form input. The element I want to…
3
votes
1 answer

Zend framework 2 - make form fields sticky when there is error submitting form

I am working on Zend framework 2. I have one form for saving shop information. I have validated the form using Zend's input filters. My issue is when I enter wrong data into the field or keep a mandatory field blank then it properly displays the…
Suyog
  • 2,472
  • 1
  • 14
  • 27
3
votes
1 answer

Zend Framework 2: How to mark form invalid?

In ZF1 it was possible to mark the form invalid using the code: $form->fieldname->addError('error message'); How can I do it in ZF2? I tried $form->get('elementName')->setMessages(array('error message')); but it doesn't make the form invalid.
Alexey Kosov
  • 3,010
  • 2
  • 23
  • 32
1
2 3 4 5 6