Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit323e301

Browse files
committed
minor#8755 Updated form/* articles to Symfony 4 (javiereguiluz)
This PR was squashed before being merged into the 4.0 branch (closes#8755).Discussion----------Updated form/* articles to Symfony 4Commits-------010f780 Fixed some issues82afb31 Updated form/* articles to Symfony 4
2 parents9ec841b +010f780 commit323e301

12 files changed

+39
-37
lines changed

‎form/action_method.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ form, you can use ``setAction()`` and ``setMethod()``:
2525
2626
class DefaultController extends Controller
2727
{
28-
public functionnewAction()
28+
public functionnew()
2929
{
3030
$form = $this->createFormBuilder($task)
3131
->setAction($this->generateUrl('target_route'))
@@ -83,7 +83,7 @@ options:
8383
8484
class DefaultController extends Controller
8585
{
86-
public functionnewAction()
86+
public functionnew()
8787
{
8888
// ...
8989

‎form/create_custom_field_type.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ link for details), create a ``shipping_widget`` block to handle this:
141141

142142
..code-block::html+php
143143

144-
<!--templates/form/shipping_widget.html.php -->
144+
<!--src/Resources/shipping_widget.html.php -->
145145
<?php if ($expanded) : ?>
146146
<ul <?php $view['form']->block($form, 'widget_container_attributes') ?>>
147147
<?php foreach ($form as $child) : ?>

‎form/create_form_type_extension.rst‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ your class as a service and using the ``form.type_extension`` tag:
7171

7272
..code-block::yaml
7373
74+
# config/services.yaml
7475
services:
7576
# ...
7677
@@ -80,6 +81,7 @@ your class as a service and using the ``form.type_extension`` tag:
8081
8182
..code-block::xml
8283
84+
<!-- config/services.xml-->
8385
<?xml version="1.0" encoding="UTF-8" ?>
8486
<containerxmlns="http://symfony.com/schema/dic/services"
8587
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -95,6 +97,7 @@ your class as a service and using the ``form.type_extension`` tag:
9597
9698
..code-block::php
9799
100+
// config/services.php
98101
use App\Form\Extension\ImageTypeExtension;
99102
use Symfony\Component\Form\Extension\Core\Type\FileType;
100103
@@ -217,7 +220,7 @@ Specifically, you need to override the ``file_widget`` block:
217220

218221
..code-block::html+twig
219222

220-
{#app/Resources/fields.html.twig #}
223+
{#templates/form/fields.html.twig #}
221224
{% extends 'form_div_layout.html.twig' %}
222225

223226
{% block file_widget %}
@@ -233,7 +236,7 @@ Specifically, you need to override the ``file_widget`` block:
233236

234237
..code-block::html+php
235238

236-
<!--app/Resources/file_widget.html.php -->
239+
<!--src/Resources/file_widget.html.php -->
237240
<?php echo $view['form']->widget($form) ?>
238241
<?php if (null !== $image_url): ?>
239242
<img src="<?php echo $view['assets']->getUrl($image_url) ?>"/>

‎form/direct_submit.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ submissions::
1010
use Symfony\Component\HttpFoundation\Request;
1111
// ...
1212

13-
public functionnewAction(Request $request)
13+
public functionnew(Request $request)
1414
{
1515
$form = $this->createFormBuilder()
1616
// ...
@@ -47,7 +47,7 @@ method, pass the submitted data directly to
4747
use Symfony\Component\HttpFoundation\Request;
4848
// ...
4949

50-
public functionnewAction(Request $request)
50+
public functionnew(Request $request)
5151
{
5252
$form = $this->createFormBuilder()
5353
// ...

‎form/dynamic_form_modification.rst‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ In a controller, create the form like normal::
344344

345345
class FriendMessageController extends Controller
346346
{
347-
public functionnewAction(Request $request)
347+
public functionnew(Request $request)
348348
{
349349
$form = $this->createForm(FriendMessageFormType::class);
350350

@@ -392,7 +392,7 @@ sport like this::
392392
{
393393
$builder
394394
->add('sport', EntityType::class, array(
395-
'class' => 'App:Sport',
395+
'class' => 'App\Entity\Sport',
396396
'placeholder' => '',
397397
))
398398
;
@@ -409,7 +409,7 @@ sport like this::
409409
$positions = null === $sport ? array() : $sport->getAvailablePositions();
410410

411411
$form->add('position', EntityType::class, array(
412-
'class' => 'App:Position',
412+
'class' => 'App\Entity\Position',
413413
'placeholder' => '',
414414
'choices' => $positions,
415415
));
@@ -456,7 +456,7 @@ The type would now look like::
456456
{
457457
$builder
458458
->add('sport', EntityType::class, array(
459-
'class' => 'App:Sport',
459+
'class' => 'App\Entity\Sport',
460460
'placeholder' => '',
461461
));
462462
;
@@ -465,7 +465,7 @@ The type would now look like::
465465
$positions = null === $sport ? array() : $sport->getAvailablePositions();
466466

467467
$form->add('position', EntityType::class, array(
468-
'class' => 'App:Position',
468+
'class' => 'App\Entity\Position',
469469
'placeholder' => '',
470470
'choices' => $positions,
471471
));
@@ -518,7 +518,7 @@ your application. Assume that you have a sport meetup creation controller::
518518

519519
class MeetupController extends Controller
520520
{
521-
public functioncreateAction(Request $request)
521+
public functioncreate(Request $request)
522522
{
523523
$meetup = new SportMeetup();
524524
$form = $this->createForm(SportMeetupType::class, $meetup);
@@ -578,7 +578,7 @@ field according to the current selection in the ``sport`` field:
578578

579579
..code-block::html+php
580580

581-
<!-- templates/Meetup/create.html.php -->
581+
<!-- templates/meetup/create.html.php -->
582582
<?php echo $view['form']->start($form) ?>
583583
<?php echo $view['form']->row($form['sport']) ?> <!-- <select id="meetup_sport" ... -->
584584
<?php echo $view['form']->row($form['position']) ?> <!-- <select id="meetup_position" ... -->

‎form/form_collections.rst‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ In your controller, you'll create a new form from the ``TaskType``::
156156

157157
class TaskController extends Controller
158158
{
159-
public functionnewAction(Request $request)
159+
public functionnew(Request $request)
160160
{
161161
$task = new Task();
162162

@@ -215,7 +215,7 @@ zero tags when first created).
215215

216216
..code-block::html+php
217217

218-
<!--src/Resources/views/Task/new.html.php -->
218+
<!--templates/task/new.html.php -->
219219

220220
<!-- ... -->
221221

@@ -399,7 +399,7 @@ one example:
399399
// Replace '__name__label__' in the prototype's HTML to
400400
// instead be a number based on how many items we have
401401
// newForm = newForm.replace(/__name__label__/g, index);
402-
402+
403403
// Replace '__name__' in the prototype's HTML to
404404
// instead be a number based on how many items we have
405405
newForm=newForm.replace(/__name__/g, index);
@@ -681,7 +681,7 @@ the relationship between the removed ``Tag`` and ``Task`` object.
681681
you'll need to do more work for the removed tags to persist correctly.
682682

683683
In this case, you can modify the controller to remove the relationship
684-
on the removed tag. This assumes that you have some ``editAction()`` which
684+
on the removed tag. This assumes that you have some ``edit()`` action which
685685
is handling the "update" of your Task::
686686

687687
// src/Controller/TaskController.php
@@ -690,7 +690,7 @@ the relationship between the removed ``Tag`` and ``Task`` object.
690690
use Doctrine\Common\Collections\ArrayCollection;
691691

692692
// ...
693-
public functioneditAction($id, Request $request)
693+
public functionedit($id, Request $request)
694694
{
695695
$em = $this->getDoctrine()->getManager();
696696
$task = $em->getRepository(Task::class)->find($id);

‎form/form_customization.rst‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ You can do this by including the ``only`` keyword after the list form themes:
366366

367367
..code-block::html+twig
368368

369-
{#app/Resources/views/common.html.twig #}
369+
{#templates/form/common.html.twig #}
370370
{% use "form_div_layout.html.twig" %}
371371

372372
{# ... #}
@@ -401,7 +401,7 @@ file in order to customize the ``integer_widget`` fragment.
401401

402402
..code-block::html+php
403403

404-
<!--templates/form/integer_widget.html.php -->
404+
<!--src/Resources/integer_widget.html.php -->
405405
<div class="integer_widget">
406406
<?php echo $view['form']->block(
407407
$form,
@@ -433,7 +433,7 @@ method:
433433

434434
The ``:form`` syntax is based on the functional names for templates:
435435
``Bundle:Directory``. As the form directory lives in the
436-
``app/Resources/views`` directory, the ``Bundle`` part is empty, resulting
436+
``templates/`` directory, the ``Bundle`` part is empty, resulting
437437
in ``:form``.
438438

439439
Referencing base Form Blocks (Twig specific)
@@ -750,7 +750,7 @@ customize the ``name`` field only:
750750

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

753-
<!--templates/form/_product_name_widget.html.php -->
753+
<!--src/Resources/_product_name_widget.html.php -->
754754
<div class="text_widget">
755755
<?php echo $view['form']->block('form_widget_simple') ?>
756756
</div>
@@ -808,7 +808,7 @@ You can also override the markup for an entire field row using the same method:
808808

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

811-
<!--templates/form/_product_name_row.html.php -->
811+
<!--src/Resources/_product_name_row.html.php -->
812812
<div class="name_row">
813813
<?php echo $view['form']->label($form) ?>
814814
<?php echo $view['form']->errors($form) ?>

‎form/form_dependencies.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ create your form::
3434
use App\Form\TaskType;
3535

3636
// ...
37-
public functionnewAction()
37+
public functionnew()
3838
{
3939
$em = $this->getDoctrine()->getManager();
4040

‎form/form_themes.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ do this, create a new template file that will store the new markup:
4141

4242
..code-block::html+php
4343

44-
<!--templates/form/form_row.html.php -->
44+
<!--src/Resources/form_row.html.php -->
4545
<div class="form_row">
4646
<?php echo $view['form']->label($form, $label) ?>
4747
<?php echo $view['form']->errors($form) ?>

‎form/use_empty_data.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ How to Configure empty Data for a Form Class
77
The ``empty_data`` option allows you to specify an empty data set for your
88
form class. This empty data set would be used if you submit your form, but
99
haven't called ``setData()`` on your form or passed in data when you created
10-
your form. For example::
10+
your form. For example, in a controller::
1111

12-
public functionindexAction()
12+
public functionindex()
1313
{
1414
$blog = ...;
1515

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp