Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions doc/book/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ namespace Application\Form;
use Application\Entity\Category;
use Zend\Form\Fieldset;
use Zend\InputFilter\InputFilterProviderInterface;
use Zend\Stdlib\Hydrator\ClassMethods as ClassMethodsHydrator;
use Zend\Hydrator\ClassMethods as ClassMethodsHydrator;

class CategoryFieldset extends Fieldset implements InputFilterProviderInterface
{
Expand Down Expand Up @@ -323,7 +323,7 @@ use Application\Entity\Product;
use Zend\Form\Element;
use Zend\Form\Fieldset;
use Zend\InputFilter\InputFilterProviderInterface;
use Zend\Stdlib\Hydrator\ClassMethods as ClassMethodsHydrator;
use Zend\Hydrator\ClassMethods as ClassMethodsHydrator;

class ProductFieldset extends Fieldset implements InputFilterProviderInterface
{
Expand Down Expand Up @@ -392,7 +392,7 @@ class ProductFieldset extends Fieldset implements InputFilterProviderInterface
'price' => [
'required' => true,
'validators' => [
array(
[
'name' => 'Float',
],
],
Expand Down Expand Up @@ -442,7 +442,7 @@ namespace Application\Form;
use Zend\Form\Element;
use Zend\Form\Form;
use Zend\InputFilter\InputFilter;
use Zend\Stdlib\Hydrator\ClassMethods as ClassMethodsHydrator;
use Zend\Hydrator\ClassMethods as ClassMethodsHydrator;

class CreateProduct extends Form
{
Expand Down Expand Up @@ -502,13 +502,13 @@ Now, let's create a zend-mvc controller action:
$form = new CreateProduct();
$product = new Product();
$form->bind($product);

$request = $this->getRequest();

if ($request->isPost()) {
$form->setData($request->getPost());

if ($form->isValid()) {
var_dump($product);
var_dump($product);
}
}

Expand All @@ -532,7 +532,6 @@ And finally, the view:
<?php
$form->setAttribute('action', $this->url('home'));
Copy link
Member

@froschdesign froschdesign Jan 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason to delete this. (See my comment above)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. so, while respectfully disagreeing, I have updated my branch (fork, whatever) per your suggestions. I'm a github noob and not sure what if anything I should do next. so please let me know, if you could. thanks!

$form->prepare();

echo $this->form()->openTag($form);

$product = $form->get('product');
Expand All @@ -547,7 +546,6 @@ echo $this->formCollection($product->get('categories'));
$brand = $product->get('brand');

// Since the brand is a 1:1 relationship, its elements are rendered normally:
echo $this->formRow($product->get('name'));
echo $this->formRow($brand->get('name'));
echo $this->formRow($brand->get('url'));

Expand Down Expand Up @@ -757,7 +755,7 @@ namespace Application\Form;
use Zend\Form\Element;
use Zend\Form\Form;
use Zend\InputFilter\InputFilter;
use Zend\Stdlib\Hydrator\ClassMethods as ClassMethodsHydrator;
use Zend\Hydrator\ClassMethods as ClassMethodsHydrator;

class CreateProduct extends Form
{
Expand Down