Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 883fde2

Browse files
committed
updated Type classes as the getName() method must now be defined
1 parent 692f4a9 commit 883fde2

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

book/forms.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,10 +643,16 @@ that will house the logic for building the product form:
643643
$builder->add('name');
644644
$builder->add('price', 'money', array('currency' => 'USD'));
645645
}
646+
647+
public function getName()
648+
{
649+
return 'product';
650+
}
646651
}
647652
648653
This new class contains all the directions needed to create the product form.
649-
It can be used to quickly build a form object in the controller:
654+
The ``getName()`` method must return a unique identifier for the type. It can
655+
be used to quickly build a form object in the controller:
650656

651657
.. code-block:: php
652658
@@ -815,6 +821,11 @@ create a form class so that a ``Category`` object can be modified by the user:
815821
'data_class' => 'Acme\StoreBundle\Entity\Category',
816822
);
817823
}
824+
825+
public function getName()
826+
{
827+
return 'category';
828+
}
818829
}
819830
820831
The type of the ``name`` field is being guessed (as a ``text`` field) from
@@ -1230,6 +1241,11 @@ The CSRF token can be customized on a form-by-form basis. For example:
12301241
'intention' => 'product_creation',
12311242
);
12321243
}
1244+
1245+
public function getName()
1246+
{
1247+
return 'product';
1248+
}
12331249
}
12341250
12351251
To disable CSRF protection, set the ``csrf_protection`` option to false.

cookbook/form/simple_signup_form_with_mongodb.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ Next, create the form for the ``User`` model::
113113
{
114114
return array('data_class' => 'Acme\AccountBundle\Document\User');
115115
}
116+
117+
public function getName()
118+
{
119+
return 'user';
120+
}
116121
}
117122

118123
We just added two fields: email and password (repeated to confirm the entered
@@ -192,6 +197,11 @@ Next, create the form for this ``Registration`` model::
192197
$builder->add('user', new UserType());
193198
$builder->add('terms', 'checkbox', array('property_path' => 'termsAccepted'));
194199
}
200+
201+
public function getName()
202+
{
203+
return 'registration';
204+
}
195205
}
196206

197207
You don't need to use special method for embedding the ``UserType`` form.

0 commit comments

Comments
 (0)