diff --git a/reference/forms/types/options/value.rst.inc b/reference/forms/types/options/value.rst.inc index d6ae41e..381aef1 100644 --- a/reference/forms/types/options/value.rst.inc +++ b/reference/forms/types/options/value.rst.inc @@ -8,6 +8,6 @@ value .. caution:: - デフォルトでチェックされたチェックチェックボックスやラジオボタンを作成するには、\ `data`_ オプションを使用します。 + デフォルトでチェックされたチェックボックスやラジオボタンを作成するには、\ `data`_ オプションを使用します。 .. 2014/05/18 yositani2002 322b21e191c19d2c2d6a83f92762f72a5122b742 diff --git a/reference/forms/types/repeated.rst b/reference/forms/types/repeated.rst index 1555354..844e391 100644 --- a/reference/forms/types/repeated.rst +++ b/reference/forms/types/repeated.rst @@ -1,110 +1,184 @@ .. index:: single: Forms; Fields; repeated -repeated Field Type -=================== - -This is a special field "group", that creates two identical fields whose -values must match (or a validation error is thrown). The most common use -is when you need the user to repeat his or her password or email to verify -accuracy. - -+-------------+------------------------------------------------------------------------+ -| Rendered as | input ``text`` field by default, but see `type`_ option | -+-------------+------------------------------------------------------------------------+ -| Options | - `type`_ | -| | - `options`_ | -| | - `first_name`_ | -| | - `second_name`_ | -+-------------+------------------------------------------------------------------------+ -| Inherited | - `invalid_message`_ | -| options | - `invalid_message_parameters`_ | -| | - `error_bubbling`_ | -+-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`field` | -+-------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType` | -+-------------+------------------------------------------------------------------------+ - -Example Usage -------------- +.. note:: + + * 対象バージョン:2.3+ + * 翻訳更新日:2014/05/24 + +repeated フィールドタイプ +========================= + +これは特別なフィールド "グループ" です。値が一致しなくてはいけない(または、検証エラーがスローされる)二つの同一のフィールドです。 +ユーザーに検証のためパスワードや電子メールを繰り返し求めるのが最も一般的な使用法です。 + ++------------------+------------------------------------------------------------------------+ +| 対応するデータ型 | ``text`` フィールドがデフォルト。 `type`_ オプションを参照 | ++------------------+------------------------------------------------------------------------+ +| オプション | - `type`_ | +| | - `options`_ | +| | - `first_options`_ | +| | - `second_options`_ | +| | - `first_name`_ | +| | - `second_name`_ | ++------------------+------------------------------------------------------------------------+ +| 上書きされた | - `error_bubbling`_ | +| オプション | | ++------------------+------------------------------------------------------------------------+ +| 継承された | - `data`_ | +| オプション | - `invalid_message`_ | +| | - `invalid_message_parameters`_ | +| | - `mapped`_ | +| | - `error_mapping`_ | ++------------------+------------------------------------------------------------------------+ +| 親タイプ | :doc:`form ` | ++------------------+------------------------------------------------------------------------+ +| クラス | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType` | ++------------------+------------------------------------------------------------------------+ + +使用例 +------ .. code-block:: php $builder->add('password', 'repeated', array( 'type' => 'password', 'invalid_message' => 'The password fields must match.', - 'options' => array('label' => 'Password'), + 'options' => array('attr' => array('class' => 'password-field')), + 'required' => true, + 'first_options' => array('label' => 'Password'), + 'second_options' => array('label' => 'Repeat Password'), )); -Upon a successful form submit, the value entered into both of the "password" -fields becomes the data of the ``password`` key. In other words, even though -two fields are actually rendered, the end data from the form is just the -single value (usually a string) that you need. +フォーム送信に成功したとき、 "password" フィールドの両方に入力された値は "password" キーのデータになります。 +つまり、実際に2つのフィールドが描画されていても、フォームからのエンドデータはあなたが必要とする単一の値(通常は文字列)です。 -The most important option is ``type``, which can be any field type and determines -the actual type of the two underlying fields. The ``options`` option is passed -to each of those individual fields, meaning - in this example - any option -supported by the ``password`` type can be passed in this array. +最も重要なオプションは、\ ``type`` です。それは、任意のフィールドタイプを設定でき、2つの対応するフィールドの実際の型を決定します。 +``options`` オプションは、それらの個々のフィールドにそれぞれに渡され、 - この例では - ``password`` タイプがサポートする任意のオプションをこの配列に渡すことができます。 + +Rendering +~~~~~~~~~ + +繰り返されるフィールドタイプは、実際には二つのフィールドを、すべてを一度に、または個別にレンダリングすることができます。 +一度にすべてをレンダリングするには、以下のように使用します。: + +.. configuration-block:: + + .. code-block:: jinja + + {{ form_row(form.password) }} + + .. code-block:: php + + row($form['password']) ?> + +個別に各フィールドをレンダリングするためには、このように使用します。: + +.. configuration-block:: + + .. code-block:: jinja + + {# .first and .second may vary in your use - see the note below #} + {{ form_row(form.password.first) }} + {{ form_row(form.password.second) }} + + .. code-block:: php + + row($form['password']['first']) ?> + row($form['password']['second']) ?> + +.. note:: + + ``first`` と ``second`` は二つのサブフィールドのデフォルトの名前です。 + しかし、これらの名前は `first_name`_ と `second_name`_ オプションを介して制御することができます。 + これらのオプションを設定している場合は、\ ``first`` と ``second`` をレンダリングするとき代わりにそれらの値を使用します。 Validation ~~~~~~~~~~ -One of the key features of the ``repeated`` field is internal validation -(you don't need to do anything to set this up) that forces the two fields -to have a matching value. If the two fields don't match, an error will be -shown to the user. +``repeated`` フィールドの主な特徴の一つは(設定するために何もする必要がない)内部検証です。2つのフィールドが一致する値を持つように強制します。 +2つのフィールドが一致しない場合、ユーザにエラーが表示されます。 -The ``invalid_message`` is used to customize the error that will -be displayed when the two fields do not match each other. +``invalid_message`` は2つのフィールドが一致しないときに表示されるエラーをカスタマイズするために使用されます。 -Field Options -------------- +フィールドオプション +-------------------- type ~~~~ -**type**: ``string`` **default**: ``text`` +**データ型**: ``string`` **デフォルト**: ``text`` -The two underlying fields will be of this field type. For example, passing -a type of ``password`` will render two password fields. +その2つのフィールドはこのフィールドタイプになります。たとえば、\ ``password`` タイプを渡すと、二つの ``password`` フィールドをレンダリングします。 options ~~~~~~~ -**type**: ``array`` **default**: ``array()`` +**データ型**: ``array`` **デフォルト**: ``array()`` -This options array will be passed to each of the two underlying fields. In -other words, these are the options that customize the individual field types. -For example, if the ``type`` option is set to ``password``, this array might -contain the options ``always_empty`` or ``required`` - both options that are -supported by the ``password`` field type. +このオプションの配列は二つのフィールドにそれぞれに渡されます。換言すれば、これらは、個々のフィールドタイプをカスタマイズするオプションがあります。 +たとえば、\ ``type`` オプションに ``password`` を設定したとき、この配列には ``always_empty`` または ``required`` が含まれるでしょう。 +どちらのオプションも ``password`` フィールドタイプでサポートされています。 + +first_options +~~~~~~~~~~~~~ + +**データ型**: ``array`` **デフォルト**: ``array()`` + +第一フィールド *だけ* に渡されるべき追加オプション( `options` にマージされます)です。 +これはラベルをカスタマイズする場合に特に便利です。:: + + $builder->add('password', 'repeated', array( + 'first_options' => array('label' => 'Password'), + 'second_options' => array('label' => 'Repeat Password'), + )); + +second_options +~~~~~~~~~~~~~~ + +**データ型**: ``array`` **デフォルト**: ``array()`` + +第二フィールド *だけ* に渡されるべき追加オプション( `options` にマージされます)です。 +これはラベルをカスタマイズする場合に特に便利です。(参照 `first_options`_ ) first_name ~~~~~~~~~~ -**type**: ``string`` **default**: ``first`` +**データ型**: ``string`` **デフォルト**: ``first`` -This is the actual field name to be used for the first field. This is mostly -meaningless, however, as the actual data entered into both of the fields will -be available under the key assigned to the ``repeated`` field itself (e.g. -``password``). However, if you don't specify a label, this field name is used -to "guess" the label for you. +これは、第一フィールドのために使用される実際のフィールド名です。 +大部分には無意味ですが、両方のフィールドに入力された実際のデータは、\ ``repeated`` フィールド自体(例えば``password``)に +割り当てられるそのキーで利用できるようになります。 +しかし、ラベルを指定しない場合はこのフィールド名はラベルを「推測」するために使用されます。 second_name ~~~~~~~~~~~ -**type**: ``string`` **default**: ``second`` +**データ型**: ``string`` **デフォルト**: ``second`` + +``first_name`` と同様ですが、第二フィールドのためのものです。 + +上書きされたオプション +---------------------- + +error_bubbling +~~~~~~~~~~~~~~ -The same as ``first_name``, but for the second field. +**デフォルト**: ``false`` -Inherited options ------------------ +継承されたオプション +-------------------- -These options inherit from the :doc:`field` type: +以下のオプションは :doc:`form ` タイプを継承しています: + +.. include:: /reference/forms/types/options/data.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/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/mapped.rst.inc + +.. include:: /reference/forms/types/options/error_mapping.rst.inc + +.. 2014/05/24 yositani2002 d49d12eaf265a5d6d32ac660c62f385d57261475