From b5510be7e5893140a32a451ed0818c9793bc637e Mon Sep 17 00:00:00 2001 From: yositani2002 Date: Fri, 20 Jun 2014 22:48:52 +0900 Subject: [PATCH] resolved #305 --- reference/forms/types/form.rst | 108 ++++++++++++++++-- reference/forms/types/options/action.rst.inc | 13 +++ .../types/options/auto_initialize.rst.inc | 10 ++ .../forms/types/options/compound.rst.inc | 10 ++ .../forms/types/options/data_class.rst.inc | 15 +++ .../forms/types/options/data_timezone.rst.inc | 9 -- .../forms/types/options/date_pattern.rst.inc | 14 --- .../options/extra_fields_message.rst.inc | 9 ++ reference/forms/types/options/method.rst.inc | 37 ++++++ reference/forms/types/options/pattern.rst.inc | 21 ++++ .../options/post_max_size_message.rst.inc | 13 +++ .../forms/types/options/property_path.rst.inc | 18 ++- .../forms/types/options/user_timezone.rst.inc | 9 -- 13 files changed, 236 insertions(+), 50 deletions(-) create mode 100644 reference/forms/types/options/action.rst.inc create mode 100644 reference/forms/types/options/auto_initialize.rst.inc create mode 100644 reference/forms/types/options/compound.rst.inc create mode 100644 reference/forms/types/options/data_class.rst.inc delete mode 100644 reference/forms/types/options/data_timezone.rst.inc delete mode 100644 reference/forms/types/options/date_pattern.rst.inc create mode 100644 reference/forms/types/options/extra_fields_message.rst.inc create mode 100644 reference/forms/types/options/method.rst.inc create mode 100644 reference/forms/types/options/pattern.rst.inc create mode 100644 reference/forms/types/options/post_max_size_message.rst.inc delete mode 100644 reference/forms/types/options/user_timezone.rst.inc diff --git a/reference/forms/types/form.rst b/reference/forms/types/form.rst index 5d74229..82a5341 100644 --- a/reference/forms/types/form.rst +++ b/reference/forms/types/form.rst @@ -3,43 +3,127 @@ .. note:: - * 対象バージョン:2.3 - * 翻訳更新日:2013/11/24 + * 対象バージョン:2.3+ + * 翻訳更新日:2014/06/20 form フィールドタイプ ===================== -:class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\FormType` を参照してください。 - -``form`` タイプはすべてのフィールドで利用可能となるいくつかのオプションをあらかじめ定義します。 +``form`` タイプを親タイプにもつすべてのタイプで利用可能なオプションを事前にいくつか定義しています。 + ++-----------+--------------------------------------------------------------------+ +|オプション | - `data`_ | +| | - `data_class`_ | +| | - `empty_data`_ | +| | - `compound`_ | +| | - `required`_ | +| | - `label_attr`_ | +| | - `constraints`_ | +| | - `cascade_validation`_ | +| | - `read_only`_ | +| | - `trim`_ | +| | - `mapped`_ | +| | - `property_path`_ | +| | - `max_length`_ (2.5 で非推奨) | +| | - `by_reference`_ | +| | - `error_bubbling`_ | +| | - `inherit_data`_ | +| | - `error_mapping`_ | +| | - `invalid_message`_ | +| | - `invalid_message_parameters`_ | +| | - `extra_fields_message`_ | +| | - `post_max_size_message`_ | +| | - `pattern`_ (2.5 で非推奨) | +| | - `action`_ | +| | - `method`_ | ++-----------+--------------------------------------------------------------------+ +| 継承された| - `block_name`_ | +| オプション| - `disabled`_ | +| | - `label`_ | +| | - `attr`_ | +| | - `translation_domain`_ | +| | - `auto_initialize`_ | ++-----------+--------------------------------------------------------------------+ +| 親クラス | none | ++-----------+--------------------------------------------------------------------+ +| クラス | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\FormType` | ++-----------+--------------------------------------------------------------------+ + +フィールドオプション +-------------------- .. include:: /reference/forms/types/options/data.rst.inc +.. include:: /reference/forms/types/options/data_class.rst.inc + +.. include:: /reference/forms/types/options/empty_data.rst.inc + +.. include:: /reference/forms/types/options/compound.rst.inc + +.. _reference-form-option-required: + .. include:: /reference/forms/types/options/required.rst.inc +.. include:: /reference/forms/types/options/label_attr.rst.inc + .. include:: /reference/forms/types/options/constraints.rst.inc .. include:: /reference/forms/types/options/cascade_validation.rst.inc .. include:: /reference/forms/types/options/read_only.rst.inc -.. include:: /reference/forms/types/options/disabled.rst.inc - .. include:: /reference/forms/types/options/trim.rst.inc .. include:: /reference/forms/types/options/mapped.rst.inc .. include:: /reference/forms/types/options/property_path.rst.inc -.. include:: /reference/forms/types/options/attr.rst.inc +.. _reference-form-option-max_length: -.. include:: /reference/forms/types/options/translation_domain.rst.inc +.. include:: /reference/forms/types/options/max_length.rst.inc + +.. include:: /reference/forms/types/options/by_reference.rst.inc + +.. include:: /reference/forms/types/options/error_bubbling.rst.inc + +.. include:: /reference/forms/types/options/inherit_data.rst.inc + +.. include:: /reference/forms/types/options/error_mapping.rst.inc + +.. include:: /reference/forms/types/options/invalid_message.rst.inc + +.. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc + +.. include:: /reference/forms/types/options/extra_fields_message.rst.inc + +.. include:: /reference/forms/types/options/post_max_size_message.rst.inc + +.. _reference-form-option-pattern: + +.. include:: /reference/forms/types/options/pattern.rst.inc + +.. include:: /reference/forms/types/options/action.rst.inc + +.. include:: /reference/forms/types/options/method.rst.inc + +継承されたオプション +-------------------- + +以下のオプションは :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\BaseType` クラスで定義されています。 +``BaseType`` クラスは ``form`` タイプと :doc:`button type ` の両方の親クラスですが、フォームタイプツリーの一部ではありません(すなわち、それ自身はフォームタイプとして利用できません)。 .. include:: /reference/forms/types/options/block_name.rst.inc -inherit_data ------------- +.. include:: /reference/forms/types/options/disabled.rst.inc + +.. include:: /reference/forms/types/options/label.rst.inc + +.. include:: /reference/forms/types/options/attr.rst.inc + +.. include:: /reference/forms/types/options/translation_domain.rst.inc + +.. include:: /reference/forms/types/options/auto_initialize.rst.inc -:doc:`/cookbook/form/inherit_data_option` を参照してください。 .. 2013/11/24 yositani2002 b675661199d466be4b6cb6f70d16aa1e3574c789 +.. 2014/06/20 yositani2002 21a4b9df8f4819b73ced858f323e835e10dfd89c \ No newline at end of file diff --git a/reference/forms/types/options/action.rst.inc b/reference/forms/types/options/action.rst.inc new file mode 100644 index 0000000..740d53e --- /dev/null +++ b/reference/forms/types/options/action.rst.inc @@ -0,0 +1,13 @@ +action +~~~~~~ + +.. versionadded:: 2.3 + ``action`` オプションは Symfony 2.3 から追加されました。 + +**データ型**: ``string`` **デフォルト**: empty string + +このオプションは、どこにフォームのデータを送信するかを指定します(通常はURI)。 +その値は ``form`` 要素の ``action`` 属性としてレンダリングされます。 +空の値は、同じドキュメント参照と見なされます。つまり、フォームは、レンダリングしたフォームと同じURIに送信されます。 + +.. 2014/06/20 yositani2002 72c30c2fa1af40af7a1f3e672005d360a898ca07 diff --git a/reference/forms/types/options/auto_initialize.rst.inc b/reference/forms/types/options/auto_initialize.rst.inc new file mode 100644 index 0000000..34df939 --- /dev/null +++ b/reference/forms/types/options/auto_initialize.rst.inc @@ -0,0 +1,10 @@ +auto_initialize +~~~~~~~~~~~~~~~ + +**データ型**: ``boolean`` **デフォルト**: ``true`` + +内部オプション:フォームを自動的に初期化されるべきかどうかを設定します。 +このオプションはすべてのフィールドでルートフォームに対しては ``true`` のみであるべきです。 +このオプションを変更する必要はありませんし、おそらくそれを心配する必要もありません。 + +.. 2014/06/20 yositani2002 58170fe71fcf76ad59047caf629357d61e41a6c3 diff --git a/reference/forms/types/options/compound.rst.inc b/reference/forms/types/options/compound.rst.inc new file mode 100644 index 0000000..2a24242 --- /dev/null +++ b/reference/forms/types/options/compound.rst.inc @@ -0,0 +1,10 @@ +compound +~~~~~~~~ + +**データ型**: ``boolean`` **デフォルト**: ``true`` + +フォームが合成物である場合は、このオプションが指定されます。 +これは、フォームが実際に子要素を持っているかどうかとは無関係です。 +フォームが合成物である時は子要素をまったく持つことができません(例えば、空のコレクション型)。 + +.. 2014/06/20 yositani2002 f6a65660b5c329c99979efa26011324f02b98628 diff --git a/reference/forms/types/options/data_class.rst.inc b/reference/forms/types/options/data_class.rst.inc new file mode 100644 index 0000000..7086aec --- /dev/null +++ b/reference/forms/types/options/data_class.rst.inc @@ -0,0 +1,15 @@ +data_class +~~~~~~~~~~ + +**データ型**: ``string`` + +このオプションは、フォームで使用する適切なデータ·マッパーを設定するために使われます。 +オブジェクトを必要とする任意のフィールドタイプに使用することができます。 + +.. code-block:: php + + $builder->add('media', 'sonata_media_type', array( + 'data_class' => 'Acme\DemoBundle\Entity\Media', + )); + +.. 2014/06/20 yositani2002 69a2ed1f816c209e477ea3560782f5a208c6f0a6 diff --git a/reference/forms/types/options/data_timezone.rst.inc b/reference/forms/types/options/data_timezone.rst.inc deleted file mode 100644 index 3f774a1..0000000 --- a/reference/forms/types/options/data_timezone.rst.inc +++ /dev/null @@ -1,9 +0,0 @@ -data_timezone -~~~~~~~~~~~~~ - -**type**: ``string`` **default**: system default timezone - -Timezone that the input data is stored in. This must be one of the -`PHP supported timezones`_ - -.. _`PHP supported timezones`: http://php.net/manual/en/timezones.php \ No newline at end of file diff --git a/reference/forms/types/options/date_pattern.rst.inc b/reference/forms/types/options/date_pattern.rst.inc deleted file mode 100644 index 8df621e..0000000 --- a/reference/forms/types/options/date_pattern.rst.inc +++ /dev/null @@ -1,14 +0,0 @@ -pattern -~~~~~~~ - -**type**: ``string`` - -This option is only relevant when the `widget`_ is set to ``choice``. -The default pattern is based off the `format`_ option, and tries to -match the characters ``M``, ``d``, and ``y`` in the format pattern. If -no match is found, the default is the string ``{{ year }}-{{ month }}-{{ day }}``. -Tokens for this option include: - - * ``{{ year }}``: Replaced with the ``year`` widget - * ``{{ month }}``: Replaced with the ``month`` widget - * ``{{ day }}``: Replaced with the ``day`` widget \ No newline at end of file diff --git a/reference/forms/types/options/extra_fields_message.rst.inc b/reference/forms/types/options/extra_fields_message.rst.inc new file mode 100644 index 0000000..370166b --- /dev/null +++ b/reference/forms/types/options/extra_fields_message.rst.inc @@ -0,0 +1,9 @@ +extra_fields_message +~~~~~~~~~~~~~~~~~~~~ + +**データ型**: ``string`` **デフォルト**: ``This form should not contain extra fields.`` + +これは検証エラーメッセージです。送信されたフォームデータに、フォーム定義の一部ではないフィールドが1つ以上含まれている場合に使われます。 +プレースホルダ ``{{extra_fields}}`` は、送信された余分なフィールド名を、カンマ区切りのリストで表示することができます。 + +.. 2014/06/20 yositani2002 dd6c0a765cc7ab3a93363f48ad59fac67bee82cb diff --git a/reference/forms/types/options/method.rst.inc b/reference/forms/types/options/method.rst.inc new file mode 100644 index 0000000..73dc7ce --- /dev/null +++ b/reference/forms/types/options/method.rst.inc @@ -0,0 +1,37 @@ +method +~~~~~~ + +.. versionadded:: 2.3 + ``method`` オプションは Symfony 2.3 から追加されました。 + +**データ型**: ``string`` **デフォルト**: ``POST`` + +このオプションでは、フォームのデータを送信するために使用されるHTTPメソッドを指定します。 +その値は ``form`` 要素の ``method`` 属性として表示されます。 +また、 ``handleRequest()`` メソッドの中で送信後、フォームの送信を処理するかどうかを決定するために使用されています。 +可能な値は次のとおりです。 +This option specifies the HTTP method used to submit the form's data. Its +value is rendered as the ``method`` attribute of the ``form`` element and is +used to decide whether to process the form submission in the +``handleRequest()`` method after submission. Possible values are: + +* POST +* GET +* PUT +* DELETE +* PATCH + +.. note: + + メソッドが PUT 、PATCH 、または DELETE の時、 Symfony は自動的にフォームに hidden フィールド ``_method`` をレンダリングします。 + これらは、"偽" のHTTPメソッドとして使用され、標準的なブラウザではサポートされていません。 + 詳細については、以下を参照してください。 + :doc:`/cookbook/routing/method_parameters` + +.. note: + + PATCH メソッドは部分データを送信することができます。 + 言い換えれば、送信されたフォームデータの特定フィールドが欠落している場合、それらは無視され、デフォルト値が(もしあれば)使用されます。 + 他のすべてのHTTPメソッドは、いくつかのフィールドが欠落している場合、それらのフィールドには ``null`` が設定されます。 + +.. 2014/06/20 yositani2002 72c30c2fa1af40af7a1f3e672005d360a898ca07 diff --git a/reference/forms/types/options/pattern.rst.inc b/reference/forms/types/options/pattern.rst.inc new file mode 100644 index 0000000..76c126f --- /dev/null +++ b/reference/forms/types/options/pattern.rst.inc @@ -0,0 +1,21 @@ +.. caution:: + + ``pattern`` オプションは非推奨となり、3.0で削除されます。 + その代わりに、``attr`` オプションに ``pattern`` キーを持つ配列を設定し使用して下さい。 + +pattern +~~~~~~~ + +**データ型**: ``string`` **デフォルト**: ``null`` + +これは HTML5 ``pattern`` 属性に指定した正規表現によるフィールド入力の制限を追加します。 + +.. caution: + + ``pattern`` 属性は利便性のためのみでクライアント側の検証を提供します。信頼性の高いサーバー側の検証の代替品として使用してはいけません。 + +.. note: + + 検証制約を使用する場合、このオプションは、サーバー側の検証と一致するように自動的にいくつかの制約を設定します。 + +.. 2014/06/20 yositani2002 456da2802373c6a6be0f719210ee791c5cf9e3ed diff --git a/reference/forms/types/options/post_max_size_message.rst.inc b/reference/forms/types/options/post_max_size_message.rst.inc new file mode 100644 index 0000000..98d470a --- /dev/null +++ b/reference/forms/types/options/post_max_size_message.rst.inc @@ -0,0 +1,13 @@ +post_max_size_message +~~~~~~~~~~~~~~~~~~~~~ + +**データ型**: ``string`` **デフォルト**: ``The uploaded file was too large. Please try to upload a smaller file.`` + +これは送信されたPOSTデータが ``php.ini`` の ``post_max_size`` ディレクティブを超えた場合に使われる検証エラーメッセージです。 +``{{ max }}`` プレースホルダは、許可されたサイズを表示するために使用することができます。 + +.. note: + + ``post_max_size`` の検証はルートフォームのみ発生します。 + +.. 2014/06/20 yositani2002 d066f4d9e7518462c837d846a59bc5b8fc1ffcd9 diff --git a/reference/forms/types/options/property_path.rst.inc b/reference/forms/types/options/property_path.rst.inc index 9ffc1f4..9f3f411 100644 --- a/reference/forms/types/options/property_path.rst.inc +++ b/reference/forms/types/options/property_path.rst.inc @@ -1,7 +1,13 @@ -* ``property_path`` [type: any, default: the field's value] - Fields display a property value of the form's domain object by default. When - the form is submitted, the submitted value is written back into the object. +property_path +~~~~~~~~~~~~~ - If you want to override the property that a field reads from and writes to, - you can set the ``property_path`` option. Its default value is the field's - name. +**データ型**: ``any`` **デフォルト**: ``the field's name`` + +フィールドには、デフォルトで、フォームのドメインオブジェクトのプロパティの値を表示します。フォームの送信時に、送信された値はオブジェクトに書き込まれます。 + +フィールドの読み取りと書き込みのプロパティを上書きしたい場合は、 ``property_path`` オプションを設定することでできます。そのデフォルト値は、フィールドの名前です。 + +オブジェクトの読み込み、書き込み時にそのフィールドを無視したい場合は、\ ``property_path`` オプションを ``false`` にすることで出来ます。しかし、その目的での ``property_path`` の使用は推奨されません。 +``mapped`` オプションを使用する必要があります。 + +.. 2014/06/20 yositani2002 6f286e18acdf003e2f1ced45b202b2578a4a47a6 diff --git a/reference/forms/types/options/user_timezone.rst.inc b/reference/forms/types/options/user_timezone.rst.inc deleted file mode 100644 index 2e63fe7..0000000 --- a/reference/forms/types/options/user_timezone.rst.inc +++ /dev/null @@ -1,9 +0,0 @@ -user_timezone -~~~~~~~~~~~~~ - -**type**: ``string`` **default**: system default timezone - -Timezone for how the data should be shown to the user (and therefore also -the data that the user submits). This must be one of the `PHP supported timezones`_ - -.. _`PHP supported timezones`: http://php.net/manual/en/timezones.php \ No newline at end of file