Skip to content

Commit 1f29810

Browse files
committed
Merge pull request #306 from yositani2002/reference-forms-types-form
[翻訳]reference/forms/types/form.rst
2 parents a8c2496 + b5510be commit 1f29810

13 files changed

+236
-50
lines changed

reference/forms/types/form.rst

Lines changed: 96 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,127 @@
33

44
.. note::
55

6-
* 対象バージョン:2.3
7-
* 翻訳更新日:2013/11/24
6+
* 対象バージョン:2.3+
7+
* 翻訳更新日:2014/06/20
88

99
form フィールドタイプ
1010
=====================
1111

12-
:class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\FormType` を参照してください。
13-
14-
``form`` タイプはすべてのフィールドで利用可能となるいくつかのオプションをあらかじめ定義します。
12+
``form`` タイプを親タイプにもつすべてのタイプで利用可能なオプションを事前にいくつか定義しています。
13+
14+
+-----------+--------------------------------------------------------------------+
15+
|オプション | - `data`_ |
16+
| | - `data_class`_ |
17+
| | - `empty_data`_ |
18+
| | - `compound`_ |
19+
| | - `required`_ |
20+
| | - `label_attr`_ |
21+
| | - `constraints`_ |
22+
| | - `cascade_validation`_ |
23+
| | - `read_only`_ |
24+
| | - `trim`_ |
25+
| | - `mapped`_ |
26+
| | - `property_path`_ |
27+
| | - `max_length`_ (2.5 で非推奨) |
28+
| | - `by_reference`_ |
29+
| | - `error_bubbling`_ |
30+
| | - `inherit_data`_ |
31+
| | - `error_mapping`_ |
32+
| | - `invalid_message`_ |
33+
| | - `invalid_message_parameters`_ |
34+
| | - `extra_fields_message`_ |
35+
| | - `post_max_size_message`_ |
36+
| | - `pattern`_ (2.5 で非推奨) |
37+
| | - `action`_ |
38+
| | - `method`_ |
39+
+-----------+--------------------------------------------------------------------+
40+
| 継承された| - `block_name`_ |
41+
| オプション| - `disabled`_ |
42+
| | - `label`_ |
43+
| | - `attr`_ |
44+
| | - `translation_domain`_ |
45+
| | - `auto_initialize`_ |
46+
+-----------+--------------------------------------------------------------------+
47+
| 親クラス | none |
48+
+-----------+--------------------------------------------------------------------+
49+
| クラス | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\FormType` |
50+
+-----------+--------------------------------------------------------------------+
51+
52+
フィールドオプション
53+
--------------------
1554

1655
.. include:: /reference/forms/types/options/data.rst.inc
1756

57+
.. include:: /reference/forms/types/options/data_class.rst.inc
58+
59+
.. include:: /reference/forms/types/options/empty_data.rst.inc
60+
61+
.. include:: /reference/forms/types/options/compound.rst.inc
62+
63+
.. _reference-form-option-required:
64+
1865
.. include:: /reference/forms/types/options/required.rst.inc
1966

67+
.. include:: /reference/forms/types/options/label_attr.rst.inc
68+
2069
.. include:: /reference/forms/types/options/constraints.rst.inc
2170

2271
.. include:: /reference/forms/types/options/cascade_validation.rst.inc
2372

2473
.. include:: /reference/forms/types/options/read_only.rst.inc
2574

26-
.. include:: /reference/forms/types/options/disabled.rst.inc
27-
2875
.. include:: /reference/forms/types/options/trim.rst.inc
2976

3077
.. include:: /reference/forms/types/options/mapped.rst.inc
3178

3279
.. include:: /reference/forms/types/options/property_path.rst.inc
3380

34-
.. include:: /reference/forms/types/options/attr.rst.inc
81+
.. _reference-form-option-max_length:
3582

36-
.. include:: /reference/forms/types/options/translation_domain.rst.inc
83+
.. include:: /reference/forms/types/options/max_length.rst.inc
84+
85+
.. include:: /reference/forms/types/options/by_reference.rst.inc
86+
87+
.. include:: /reference/forms/types/options/error_bubbling.rst.inc
88+
89+
.. include:: /reference/forms/types/options/inherit_data.rst.inc
90+
91+
.. include:: /reference/forms/types/options/error_mapping.rst.inc
92+
93+
.. include:: /reference/forms/types/options/invalid_message.rst.inc
94+
95+
.. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc
96+
97+
.. include:: /reference/forms/types/options/extra_fields_message.rst.inc
98+
99+
.. include:: /reference/forms/types/options/post_max_size_message.rst.inc
100+
101+
.. _reference-form-option-pattern:
102+
103+
.. include:: /reference/forms/types/options/pattern.rst.inc
104+
105+
.. include:: /reference/forms/types/options/action.rst.inc
106+
107+
.. include:: /reference/forms/types/options/method.rst.inc
108+
109+
継承されたオプション
110+
--------------------
111+
112+
以下のオプションは :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\BaseType` クラスで定義されています。
113+
``BaseType`` クラスは ``form`` タイプと :doc:`button type </reference/forms/types/button>` の両方の親クラスですが、フォームタイプツリーの一部ではありません(すなわち、それ自身はフォームタイプとして利用できません)。
37114

38115
.. include:: /reference/forms/types/options/block_name.rst.inc
39116

40-
inherit_data
41-
------------
117+
.. include:: /reference/forms/types/options/disabled.rst.inc
118+
119+
.. include:: /reference/forms/types/options/label.rst.inc
120+
121+
.. include:: /reference/forms/types/options/attr.rst.inc
122+
123+
.. include:: /reference/forms/types/options/translation_domain.rst.inc
124+
125+
.. include:: /reference/forms/types/options/auto_initialize.rst.inc
42126

43-
:doc:`/cookbook/form/inherit_data_option` を参照してください。
44127

45128
.. 2013/11/24 yositani2002 b675661199d466be4b6cb6f70d16aa1e3574c789
129+
.. 2014/06/20 yositani2002 21a4b9df8f4819b73ced858f323e835e10dfd89c
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
action
2+
~~~~~~
3+
4+
.. versionadded:: 2.3
5+
``action`` オプションは Symfony 2.3 から追加されました。
6+
7+
**データ型**: ``string`` **デフォルト**: empty string
8+
9+
このオプションは、どこにフォームのデータを送信するかを指定します(通常はURI)。
10+
その値は ``form`` 要素の ``action`` 属性としてレンダリングされます。
11+
空の値は、同じドキュメント参照と見なされます。つまり、フォームは、レンダリングしたフォームと同じURIに送信されます。
12+
13+
.. 2014/06/20 yositani2002 72c30c2fa1af40af7a1f3e672005d360a898ca07
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
auto_initialize
2+
~~~~~~~~~~~~~~~
3+
4+
**データ型**: ``boolean`` **デフォルト**: ``true``
5+
6+
内部オプション:フォームを自動的に初期化されるべきかどうかを設定します。
7+
このオプションはすべてのフィールドでルートフォームに対しては ``true`` のみであるべきです。
8+
このオプションを変更する必要はありませんし、おそらくそれを心配する必要もありません。
9+
10+
.. 2014/06/20 yositani2002 58170fe71fcf76ad59047caf629357d61e41a6c3
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
compound
2+
~~~~~~~~
3+
4+
**データ型**: ``boolean`` **デフォルト**: ``true``
5+
6+
フォームが合成物である場合は、このオプションが指定されます。
7+
これは、フォームが実際に子要素を持っているかどうかとは無関係です。
8+
フォームが合成物である時は子要素をまったく持つことができません(例えば、空のコレクション型)。
9+
10+
.. 2014/06/20 yositani2002 f6a65660b5c329c99979efa26011324f02b98628
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
data_class
2+
~~~~~~~~~~
3+
4+
**データ型**: ``string``
5+
6+
このオプションは、フォームで使用する適切なデータ·マッパーを設定するために使われます。
7+
オブジェクトを必要とする任意のフィールドタイプに使用することができます。
8+
9+
.. code-block:: php
10+
11+
$builder->add('media', 'sonata_media_type', array(
12+
'data_class' => 'Acme\DemoBundle\Entity\Media',
13+
));
14+
15+
.. 2014/06/20 yositani2002 69a2ed1f816c209e477ea3560782f5a208c6f0a6

reference/forms/types/options/data_timezone.rst.inc

Lines changed: 0 additions & 9 deletions
This file was deleted.

reference/forms/types/options/date_pattern.rst.inc

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
extra_fields_message
2+
~~~~~~~~~~~~~~~~~~~~
3+
4+
**データ型**: ``string`` **デフォルト**: ``This form should not contain extra fields.``
5+
6+
これは検証エラーメッセージです。送信されたフォームデータに、フォーム定義の一部ではないフィールドが1つ以上含まれている場合に使われます。
7+
プレースホルダ ``{{extra_fields}}`` は、送信された余分なフィールド名を、カンマ区切りのリストで表示することができます。
8+
9+
.. 2014/06/20 yositani2002 dd6c0a765cc7ab3a93363f48ad59fac67bee82cb
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
method
2+
~~~~~~
3+
4+
.. versionadded:: 2.3
5+
``method`` オプションは Symfony 2.3 から追加されました。
6+
7+
**データ型**: ``string`` **デフォルト**: ``POST``
8+
9+
このオプションでは、フォームのデータを送信するために使用されるHTTPメソッドを指定します。
10+
その値は ``form`` 要素の ``method`` 属性として表示されます。
11+
また、 ``handleRequest()`` メソッドの中で送信後、フォームの送信を処理するかどうかを決定するために使用されています。
12+
可能な値は次のとおりです。
13+
This option specifies the HTTP method used to submit the form's data. Its
14+
value is rendered as the ``method`` attribute of the ``form`` element and is
15+
used to decide whether to process the form submission in the
16+
``handleRequest()`` method after submission. Possible values are:
17+
18+
* POST
19+
* GET
20+
* PUT
21+
* DELETE
22+
* PATCH
23+
24+
.. note:
25+
26+
メソッドが PUT 、PATCH 、または DELETE の時、 Symfony は自動的にフォームに hidden フィールド ``_method`` をレンダリングします。
27+
これらは、"偽" のHTTPメソッドとして使用され、標準的なブラウザではサポートされていません。
28+
詳細については、以下を参照してください。
29+
:doc:`/cookbook/routing/method_parameters`
30+
31+
.. note:
32+
33+
PATCH メソッドは部分データを送信することができます。
34+
言い換えれば、送信されたフォームデータの特定フィールドが欠落している場合、それらは無視され、デフォルト値が(もしあれば)使用されます。
35+
他のすべてのHTTPメソッドは、いくつかのフィールドが欠落している場合、それらのフィールドには ``null`` が設定されます。
36+
37+
.. 2014/06/20 yositani2002 72c30c2fa1af40af7a1f3e672005d360a898ca07
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. caution::
2+
3+
``pattern`` オプションは非推奨となり、3.0で削除されます。
4+
その代わりに、``attr`` オプションに ``pattern`` キーを持つ配列を設定し使用して下さい。
5+
6+
pattern
7+
~~~~~~~
8+
9+
**データ型**: ``string`` **デフォルト**: ``null``
10+
11+
これは HTML5 ``pattern`` 属性に指定した正規表現によるフィールド入力の制限を追加します。
12+
13+
.. caution:
14+
15+
``pattern`` 属性は利便性のためのみでクライアント側の検証を提供します。信頼性の高いサーバー側の検証の代替品として使用してはいけません。
16+
17+
.. note:
18+
19+
検証制約を使用する場合、このオプションは、サーバー側の検証と一致するように自動的にいくつかの制約を設定します。
20+
21+
.. 2014/06/20 yositani2002 456da2802373c6a6be0f719210ee791c5cf9e3ed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
post_max_size_message
2+
~~~~~~~~~~~~~~~~~~~~~
3+
4+
**データ型**: ``string`` **デフォルト**: ``The uploaded file was too large. Please try to upload a smaller file.``
5+
6+
これは送信されたPOSTデータが ``php.ini`` の ``post_max_size`` ディレクティブを超えた場合に使われる検証エラーメッセージです。
7+
``{{ max }}`` プレースホルダは、許可されたサイズを表示するために使用することができます。
8+
9+
.. note:
10+
11+
``post_max_size`` の検証はルートフォームのみ発生します。
12+
13+
.. 2014/06/20 yositani2002 d066f4d9e7518462c837d846a59bc5b8fc1ffcd9
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
* ``property_path`` [type: any, default: the field's value]
2-
Fields display a property value of the form's domain object by default. When
3-
the form is submitted, the submitted value is written back into the object.
1+
property_path
2+
~~~~~~~~~~~~~
43

5-
If you want to override the property that a field reads from and writes to,
6-
you can set the ``property_path`` option. Its default value is the field's
7-
name.
4+
**データ型**: ``any`` **デフォルト**: ``the field's name``
5+
6+
フィールドには、デフォルトで、フォームのドメインオブジェクトのプロパティの値を表示します。フォームの送信時に、送信された値はオブジェクトに書き込まれます。
7+
8+
フィールドの読み取りと書き込みのプロパティを上書きしたい場合は、 ``property_path`` オプションを設定することでできます。そのデフォルト値は、フィールドの名前です。
9+
10+
オブジェクトの読み込み、書き込み時にそのフィールドを無視したい場合は、\ ``property_path`` オプションを ``false`` にすることで出来ます。しかし、その目的での ``property_path`` の使用は推奨されません。
11+
``mapped`` オプションを使用する必要があります。
12+
13+
.. 2014/06/20 yositani2002 6f286e18acdf003e2f1ced45b202b2578a4a47a6

reference/forms/types/options/user_timezone.rst.inc

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)