8000 Revert some changes and fix template names · GromNaN/symfony-docs@99cdc00 · GitHub
[go: up one dir, main page]

Skip to content

Commit 99cdc00

Browse files
committed
Revert some changes and fix template names
1 parent 2b00abe commit 99cdc00

File tree

4 files changed

+41
-40
lines changed

4 files changed

+41
-40
lines changed

book/doctrine.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,8 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
953953
products:
954954
targetEntity: Product
955955
mappedBy: category
956+
# Don't forget to initialize the collection in
957+
# the __construct() method of the entity
956958
957959
.. code-block:: xml
958960

book/forms.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ from inside a controller::
9797
->getForm();
9898

9999
return $this->render('default/new.html.twig', array(
100-
'form' => $form->createView()
100+
'form' => $form->createView(),
101101
));
102102
}
103103
}
@@ -212,8 +212,8 @@ Handling Form Submissions
212212

213213
The second job of a form is to translate user-submitted data back to the
214214
properties of an object. To make this happen, the submitted data from the
215-
user must be written into ``$form``. Add the following functionality to your
216-
controller::
215+
user must be written into the Form object. Add the following functionality to
216+
your controller::
217217

218218
// ...
219219
use Symfony\Component\HttpFoundation\Request;
@@ -681,10 +681,12 @@ the documentation for each type.
681681
that HTML5-ready browsers will apply client-side validation if the field
682682
is left blank. If you don't want this behavior, either
683683
:ref:`disable HTML5 validation <book-forms-html5-validation-disable>`
684-
or set the ``required`` option on your field to ``false``:
684+
or set the ``required`` option on your field to ``false``::
685685
686-
->add('dueDate', 'date', array('widget' => 'single_text',
687-
'required' => false))
686+
->add('dueDate', 'date', array(
687+
'widget' => 'single_text',
688+
'required' => false
689+
))
688690

689691
Also note that setting the ``required`` option to ``true`` will **not**
690692
result in server-side validation to be applied. In other words, if a

book/templating.rst

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -370,19 +370,6 @@ When working with template inheritance, here are some tips to keep in mind:
370370
{{ parent() }}
371371
{% endblock %}
372372

373-
* Blocks can be nested. For better overview, you can add the block name to the
374-
``{% endblock %}`` tag like this:
375-
376-
.. code-block:: html+jinja
377-
378-
{% block foo %}
379-
{# ... #}
380-
{% block bar %}
381-
{# ... #}
382-
{% endblock bar %}
383-
{# ... #}
384-
{% endblock foo %}
385-
386373
.. index::
387374
single: Templating; Naming conventions
388375
single: Templating; File locations

cookbook/form/form_customization.rst

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ directly in the template that's actually rendering the form.
243243

244244
.. code-block:: html+twig
245245

246-
{% extends '::base.html.twig' %}
246+
{% extends 'base.html.twig' %}
247247

248248
{% form_theme form _self %}
249249

@@ -282,7 +282,7 @@ can now re-use the form customization across many templates:
282282

283283
.. code-block:: html+twig
284284

285-
{# src/AppBundle/Resources/views/Form/fields.html.twig #}
285+
{# app/Resources/views/form/fields.html.twig #}
286286
{% block integer_widget %}
287287
<div class="integer_widget">
288288
{% set type = type|default('number') %}
@@ -298,7 +298,7 @@ tell Symfony to use the template via the ``form_theme`` tag:
298298

299299
.. code-block:: html+twig
300300

301-
{% form_theme form 'AppBundle:Form:fields.html.twig' %}
301+
{% form_theme form 'form/fields.html.twig' %}
302302

303303
{{ form_widget(form.age) }}
304304

@@ -314,13 +314,12 @@ name of all the templates as an array using the ``with`` keyword:
314314

315315
.. code-block:: html+twig
316316

317-
{% form_theme form with ['::common.html.twig', ':Form:fields.html.twig',
318-
'AppBundle:Form:fields.html.twig'] %}
317+
{% form_theme form with ['common.html.twig', 'form/fields.html.twig'] %}
319318

320319
{# ... #}
321320

322-
The templates can be located at different bundles and they can even be stored
323-
at the global ``app/Resources/views/`` directory.
321+
The templates can also be located in different bundles, use the functional name
322+
to reference these templates, e.g. ``AcmeFormExtraBundle:form:fields.html.twig``.
324323

325324
Child Forms
326325
...........
@@ -329,16 +328,16 @@ You can also apply a form theme to a specific child of your form:
329328

330329
.. code-block:: html+twig
331330

332-
{% form_theme form.child 'AppBundle:Form:fields.html.twig' %}
331+
{% form_theme form.child 'form/fields.html.twig' %}
333332

334333
This is useful when you want to have a custom theme for a nested form that's
335334
different than the one of your main form. Just specify both your themes:
336335

337336
.. code-block:: html+twig
338337

339-
{% form_theme form 'AppBundle:Form:fields.html.twig' %}
338+
{% form_theme form 'form/fields.html.twig' %}
340339

341-
{% form_theme form.child 'AppBundle:Form:fields_child.html.twig' %}
340+
{% form_theme form.child 'form/fields_child.html.twig' %}
342341

343342
.. _cookbook-form-php-theming:
344343

@@ -354,9 +353,13 @@ file in order to customize the ``integer_widget`` fragment.
354353

355354
.. code-block:: html+php
356355

357-
<!-- app/Resources/views/Form/integer_widget.html.php -->
356+
<!-- app/Resources/views/form/integer_widget.html.php -->
358357
<div class="integer_widget">
359-
<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : "number")) ?>
358+
<?php echo $view['form']->block(
359+
$form,
360+
'form_widget_simple',
361+
array('type' => isset($type) ? $type : "number")
362+
) ?>
360363
</div>
361364

362365
Now that you've created the customized form template, you need to tell Symfony
@@ -367,7 +370,7 @@ tell Symfony to use the theme via the ``setTheme`` helper method:
367370

368371
.. code-block:: php
369372
370-
<?php $view['form']->setTheme($form, array('AppBundle:Form')); ?>
373+
<?php $view['form']->setTheme($form, array(':form')); ?>
371374
372375
<?php $view['form']->widget($form['age']) ?>
373376
@@ -380,7 +383,14 @@ method:
380383

381384
.. code-block:: php
382385
383-
<?php $view['form']->setTheme($form['child'], 'AppBundle:Form/Child'); ?>
386+
<?php $view['form']->setTheme($form['child'], ':form'); ?>
387+
388+
.. note::
389+
390+
The ``:form`` syntax is based on the functional names for templates:
391+
``Bundle:Directory``. As the form directory lives in the
392+
``app/Resources/views`` directory, the ``Bundle`` part is empty, resulting
393+
in ``:form``.
384394

385395
.. _cookbook-form-twig-import-base-blocks:
386396

@@ -454,8 +464,8 @@ Twig
454464
~~~~
455465

456466
By using the following configuration, any customized form blocks inside the
457-
``AppBundle:Form:fields.html.twig`` template will be used globally when a
458-
form is rendered.
467+
``form/fields.html.twig`` template will be used globally when a form is
468+
rendered.
459469

460470
.. configuration-block::
461471

@@ -465,15 +475,15 @@ form is rendered.
465475
twig:
466476
form:
467477
resources:
468-
- 'AppBundle:Form:fields.html.twig'
478+
- 'form/fields.html.twig'
469479
# ...
470480
471481
.. code-block:: xml
472482
473483
<!-- app/config/config.xml -->
474484
<twig:config>
475485
<twig:form>
476-
<resource>AppBundle:Form:fields.html.twig</resource>
486+
<resource>form/fields.html.twig</resource>
477487
</twig:form>
478488
<!-- ... -->
479489
</twig:config>
@@ -484,7 +494,7 @@ form is rendered.
484494
$container->loadFromExtension('twig', array(
485495
'form' => array(
486496
'resources' => array(
487-
'AppBundle:Form:fields.html.twig',
497+
'form/fields.html.twig',
488498
),
489499
),
490500
@@ -666,7 +676,7 @@ customize the ``name`` field only:
666676
.. code-block:: html+php
667677

668678
<!-- Main template -->
669-
<?php echo $view['form']->setTheme($form, array('AppBundle:Form')); ?>
679+
<?php echo $view['form']->setTheme($form, array(':form')); ?>
670680

671681
<?php echo $view['form']->widget($form['name']); ?>
672682

@@ -723,7 +733,7 @@ You can also override the markup for an entire field row using the same method:
723733
.. code-block:: html+php
724734

725735
<!-- Main template -->
726-
<?php echo $view['form']->setTheme($form, array('AppBundle:Form')); ?>
736+
<?php echo $view['form']->setTheme($form, array(':form')); ?>
727737

728738
<?php echo $view['form']->row($form['name']); ?>
729739

0 commit comments

Comments
 (0)
0