{"id":184484,"date":"2013-06-24T21:52:03","date_gmt":"2013-06-24T17:52:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=184484"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=184484","title":{"rendered":"<span class=\"post_title\">\u0420\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c Symfony 2 Forms<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h4>\u041f\u0440\u0435\u043b\u044e\u0434\u0438\u044f<\/h4>\n<p>  \u0424\u043e\u0440\u043c\u044b, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 Symfony2. \u041d\u043e \u0437\u0430 \u0432\u0441\u0435\u0439 \u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0433\u0438\u0431\u043a\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f \u0448\u0438\u0440\u043e\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f. \u041c\u044b, \u043a\u0430\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c (\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c) \u0442\u0438\u043f\u044b \u043f\u043e\u043b\u0435\u0439 \u0444\u043e\u0440\u043c (Form Type), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0438 (Event Listeners), \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (Data Transformers) \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 (Type Extensions). \u041e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0438 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0422\u0435\u043e\u0440\u0438\u044f<\/h4>\n<p>  \u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043c\u043e\u0449\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f (FormView) \u0442\u0438\u043f\u043e\u0432 \u043f\u043e\u043b\u0435\u0439. \u0412 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f 4 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438:  <\/p>\n<pre><code class=\"php\">public function buildForm(FormBuilderInterface $builder, array $options) { }  public function buildView(FormView $view, FormInterface $form, array $options) { }  public function finishView(FormView $view, FormInterface $form, array $options) { }  public function setDefaultOptions(OptionsResolverInterface $resolver) { } <\/code><\/pre>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0445 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435:  <\/p>\n<ol>\n<li><b>buildForm<\/b> &mdash; \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 <b>FormBuilder<\/b>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u044f \u0444\u043e\u0440\u043c\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u0439;<\/li>\n<li><b>buildView<\/b> &mdash; \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c <b>FormView<\/b> \u0438 <b>Form<\/b>, \u0434\u043b\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u044b. \u0412 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f;<\/li>\n<li><b>finishView<\/b> &mdash; \u0441\u0445\u043e\u0436 \u0441 <b>buildView<\/b>, \u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f;<\/li>\n<li><b>setDefaultOptions<\/b> &mdash; \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 <b>OptionsResolver<\/b>, \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043e\u043f\u0446\u0438\u0439.<\/li>\n<\/ol>\n<p>  \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 <b>setDefaultOptions<\/b> \u0438 <b>buildView<\/b>. \u041e\u0434\u0438\u043d \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u0444\u043e\u0440\u043c:  <\/p>\n<ol>\n<li><b>setDefaultOptions<\/b> &mdash; \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u043e\u043f\u0446\u0438\u044e \u0432 <b>OptionsResolver<\/b>;<\/li>\n<li><b>buildView<\/b> &mdash; \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u0446\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435;<\/li>\n<li>\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d \u0444\u043e\u0440\u043c\u044b \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430.<\/li>\n<\/ol>\n<p>  \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u043f\u043e\u043b\u0435\u0439 \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043d\u0430\u043c \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 getExtendedType:  <\/p>\n<pre><code class=\"php\">public function getExtendedType() {     \/\/ \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0435\u0439 \u0442\u0438\u043f\u0430 textarea     return 'textarea'; } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0432 Symfony 2 Framework \u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0441\u0435\u0440\u0432\u0438\u0441 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 (Dependency Injection Container) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u044d\u0433\u0430 \u2014 <b>form.type_extension<\/b>. \u0414\u043b\u044f \u0442\u044d\u0433\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <b>alias<\/b> \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u0430 \u043f\u043e\u043b\u0435\u0439 \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435:  <\/p>\n<pre><code class=\"php\">services:     acme_demo.form.my_extension:         class: Acme\\DemoBundle\\Form\\Extension\\MyExtension         tags:             - { name: form.type_extension, alias: textarea } <\/code><\/pre>\n<p>  <\/p>\n<h4>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430<\/h4>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0435 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044f \u0444\u043e\u0440\u043c\u044b \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0438\u0445 \u0432\u043d\u0443\u0442\u0440\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 &lt;fieldset&gt;.  <\/p>\n<pre><code class=\"php\">&lt;?php  namespace Acme\\DemoBundle\\Form\\Extension;  use Symfony\\Component\\Form\\AbstractTypeExtension; use Symfony\\Component\\Form\\FormView; use Symfony\\Component\\Form\\FormInterface; use Symfony\\Component\\OptionsResolver\\OptionsResolverInterface; use Symfony\\Component\\OptionsResolver\\Options;  class FieldsetExtension extends AbstractTypeExtension {     private $rootView;      public function getExtendedType()     {         \/\/ \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u043f\u043e\u043b\u0435\u0439         return 'form';     }      public function setDefaultOptions(OptionsResolverInterface $resolver)     {         $resolver-&gt;setDefaults(array(             \/\/ \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0430 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.             'group' =&gt; null,         ));     }      public function buildView(FormView $view, FormInterface $form, array $options)     {         $group = $options['group'];          if (null === $group) {             return;         }          $root = $this-&gt;getRootView($view);         $root-&gt;vars['groups'][$group][] = $form-&gt;getName();     }      public function getRootView(FormView $view)     {         $root = $view-&gt;parent;          while (null === $root) {             $root = $root-&gt;parent;         }          return $root;     } } <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0448\u0430\u0431\u043b\u043e\u043d \u0444\u043e\u0440\u043c:  <\/p>\n<pre><code class=\"html\">{# src Acme\/DemoBundle\/Resources\/views\/Form\/fields.html.twig #} {% extends 'form_div_layout.html.twig' %}  {% block form_widget_compound %} &lt;div {{ block('widget_container_attributes') }}&gt;     {% if form.parent is empty %}         {{ form_errors(form) }}     {% endif %}     {% if form.vars.groups is defined %}         {% for group,items in form.vars.groups %}         &lt;fieldset&gt;             &lt;legend&gt;{{ group|title|trans({}, translation_domain) }}&lt;\/legend&gt;             {% for item in items %}                 {{ form_row(form[item]) }}             {% endfor %}         &lt;\/fieldset&gt;         {% endfor %}     {% endif %}     {{ form_rest(form) }} &lt;\/div&gt; {% endblock form_widget_compound %} <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u0444\u043e\u0440\u043c\u0443:  <\/p>\n<pre><code class=\"php\">&lt;?php  namespace Acme\\DemoBundle\\Form\\Extension;  use Symfony\\Component\\Form\\AbstractType; use Symfony\\Component\\Form\\FormBuilderInterface; use Symfony\\Component\\OptionsResolver\\OptionsResolverInterface;  class PersonType extends AbstractType {     public function buildForm(FormBuilderInterface $builder, array $options)     {         $builder             -&gt;add('name', 'text', array(                 'group' =&gt; 'fio'             ))             -&gt;add('surname', 'text', array(                 'group' =&gt; 'fio'             ))             -&gt;add('midname', 'text', array(                 'group' =&gt; 'fio'             ))             -&gt;add('phone', 'text', array(                 'group' =&gt; 'contacts'             ))             -&gt;add('skype', 'text', array(                 'group' =&gt; 'contacts'             ))             -&gt;add('email', 'text', array(                 'group' =&gt; 'contacts'             ))         ;     } } <\/code><\/pre>\n<p>  \u0418 \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f \u043d\u0435\u0451:  <\/p>\n<pre><code class=\"html\">{# src Acme\/DemoBundle\/Resources\/views\/Person\/new.html.twig #} {% form_theme form 'AcmeDemoBundle:Form:fields.html.twig' %}  &lt;form action=&quot;{{ path('person_create') }}&quot; &gt;     {{ form_widget(form) }} &lt;\/form&gt; <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u0430, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0430\u0445\u0430\u0440\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441-\u043e\u0431\u0435\u0440\u0442\u043a\u0443:  <\/p>\n<pre><code class=\"php\">&lt;?php  namespace Acme\\DemoBundle\\Form;  use Symfony\\Component\\Form\\FormBuilder;  class FormMapper {     \/**      * Form builder      * @var FormBuidler      *\/     private $builder;      \/**      * Active group      * @var mixed null|string      *\/     private $group = null;      public function __construct(FormBuilder $builder)     {         $this-&gt;builder = $builder;     }      \/**      * Add child to builder with group option      *\/     public function add($child, $type = null, array $options = array())     {         if (!array_key_exists('group', $options) and null !== $this-&gt;group) {             $options['group'] = $this-&gt;group;         }          $this-&gt;builder-&gt;add($child, $type, $options);          return $this;     }      \/**      * Set active group      *\/     public function with($group)     {         $this-&gt;group = $group;          return $this;     } } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438 \u0441\u0442\u0430\u043b\u043e \u043f\u0440\u043e\u0449\u0435:  <\/p>\n<pre><code class=\"php\">public function buildForm(FormBuilderInterface $builder, array $options) {     $mapper = new FormMapper($builder);     $mapper         -&gt;with('fio')             -&gt;add('name', 'text')             -&gt;add('surname', 'text')             -&gt;add('midname', 'text')         -&gt;with('contacts')             -&gt;add('phone', 'text')             -&gt;add('skype', 'text')             -&gt;add('email', 'text')     ; } <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0424\u0438\u043d\u0430\u043b<\/h4>\n<p>  \u041f\u0440\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b:  <\/p>\n<ol>\n<li><a href=\"http:\/\/symfony.com\/doc\/master\/book\/forms.html\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Symfony 2 Form Component<\/a><\/li>\n<li><a href=\"http:\/\/symfony.com\/doc\/master\/cookbook\/form\/index.html\">\u0420\u0435\u0446\u0435\u043f\u0442\u044b Symfony 2 Forms<\/a><\/li>\n<\/ol>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/184484\/\"> http:\/\/habrahabr.ru\/post\/184484\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h4>\u041f\u0440\u0435\u043b\u044e\u0434\u0438\u044f<\/h4>\n<p>  \u0424\u043e\u0440\u043c\u044b, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 Symfony2. \u041d\u043e \u0437\u0430 \u0432\u0441\u0435\u0439 \u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0433\u0438\u0431\u043a\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f \u0448\u0438\u0440\u043e\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f. \u041c\u044b, \u043a\u0430\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c (\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c) \u0442\u0438\u043f\u044b \u043f\u043e\u043b\u0435\u0439 \u0444\u043e\u0440\u043c (Form Type), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0438 (Event Listeners), \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (Data Transformers) \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 (Type Extensions). \u041e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0438 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-184484","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/184484","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=184484"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/184484\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=184484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=184484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=184484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}