Skip to content

Commit a8c2496

Browse files
committed
Merge pull request #304 from yositani2002/repeated-type
[翻訳]reference/forms/types/repeated.rst
2 parents 6458980 + 408fd2d commit a8c2496

File tree

2 files changed

+140
-66
lines changed

2 files changed

+140
-66
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ value
88

99
.. caution::
1010

11-
デフォルトでチェックされたチェックチェックボックスやラジオボタンを作成するには、\ `data`_ オプションを使用します。
11+
デフォルトでチェックされたチェックボックスやラジオボタンを作成するには、\ `data`_ オプションを使用します。
1212

1313
.. 2014/05/18 yositani2002 322b21e191c19d2c2d6a83f92762f72a5122b742

reference/forms/types/repeated.rst

Lines changed: 139 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,184 @@
11
.. index::
22
single: Forms; Fields; repeated
33

4-
repeated Field Type
5-
===================
6-
7-
This is a special field "group", that creates two identical fields whose
8-
values must match (or a validation error is thrown). The most common use
9-
is when you need the user to repeat his or her password or email to verify
10-
accuracy.
11-
12-
+-------------+------------------------------------------------------------------------+
13-
| Rendered as | input ``text`` field by default, but see `type`_ option |
14-
+-------------+------------------------------------------------------------------------+
15-
| Options | - `type`_ |
16-
| | - `options`_ |
17-
| | - `first_name`_ |
18-
| | - `second_name`_ |
19-
+-------------+------------------------------------------------------------------------+
20-
| Inherited | - `invalid_message`_ |
21-
| options | - `invalid_message_parameters`_ |
22-
| | - `error_bubbling`_ |
23-
+-------------+------------------------------------------------------------------------+
24-
| Parent type | :doc:`field</reference/forms/types/form>` |
25-
+-------------+------------------------------------------------------------------------+
26-
| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType` |
27-
+-------------+------------------------------------------------------------------------+
28-
29-
Example Usage
30-
-------------
4+
.. note::
5+
6+
* 対象バージョン:2.3+
7+
* 翻訳更新日:2014/05/24
8+
9+
repeated フィールドタイプ
10+
=========================
11+
12+
これは特別なフィールド "グループ" です。値が一致しなくてはいけない(または、検証エラーがスローされる)二つの同一のフィールドです。
13+
ユーザーに検証のためパスワードや電子メールを繰り返し求めるのが最も一般的な使用法です。
14+
15+
+------------------+------------------------------------------------------------------------+
16+
| 対応するデータ型 | ``text`` フィールドがデフォルト。 `type`_ オプションを参照 |
17+
+------------------+------------------------------------------------------------------------+
18+
| オプション | - `type`_ |
19+
| | - `options`_ |
20+
| | - `first_options`_ |
21+
| | - `second_options`_ |
22+
| | - `first_name`_ |
23+
| | - `second_name`_ |
24+
+------------------+------------------------------------------------------------------------+
25+
| 上書きされた | - `error_bubbling`_ |
26+
| オプション | |
27+
+------------------+------------------------------------------------------------------------+
28+
| 継承された | - `data`_ |
29+
| オプション | - `invalid_message`_ |
30+
| | - `invalid_message_parameters`_ |
31+
| | - `mapped`_ |
32+
| | - `error_mapping`_ |
33+
+------------------+------------------------------------------------------------------------+
34+
| 親タイプ | :doc:`form </reference/forms/types/form>` |
35+
+------------------+------------------------------------------------------------------------+
36+
| クラス | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType` |
37+
+------------------+------------------------------------------------------------------------+
38+
39+
使用例
40+
------
3141

3242
.. code-block:: php
3343
3444
$builder->add('password', 'repeated', array(
3545
'type' => 'password',
3646
'invalid_message' => 'The password fields must match.',
37-
'options' => array('label' => 'Password'),
47+
'options' => array('attr' => array('class' => 'password-field')),
48+
'required' => true,
49+
'first_options' => array('label' => 'Password'),
50+
'second_options' => array('label' => 'Repeat Password'),
3851
));
3952
40-
Upon a successful form submit, the value entered into both of the "password"
41-
fields becomes the data of the ``password`` key. In other words, even though
42-
two fields are actually rendered, the end data from the form is just the
43-
single value (usually a string) that you need.
53+
フォーム送信に成功したとき、 "password" フィールドの両方に入力された値は "password" キーのデータになります。
54+
つまり、実際に2つのフィールドが描画されていても、フォームからのエンドデータはあなたが必要とする単一の値(通常は文字列)です。
4455

45-
The most important option is ``type``, which can be any field type and determines
46-
the actual type of the two underlying fields. The ``options`` option is passed
47-
to each of those individual fields, meaning - in this example - any option
48-
supported by the ``password`` type can be passed in this array.
56+
最も重要なオプションは、\ ``type`` です。それは、任意のフィールドタイプを設定でき、2つの対応するフィールドの実際の型を決定します。
57+
``options`` オプションは、それらの個々のフィールドにそれぞれに渡され、 - この例では - ``password`` タイプがサポートする任意のオプションをこの配列に渡すことができます。
58+
59+
Rendering
60+
~~~~~~~~~
61+
62+
繰り返されるフィールドタイプは、実際には二つのフィールドを、すべてを一度に、または個別にレンダリングすることができます。
63+
一度にすべてをレンダリングするには、以下のように使用します。:
64+
65+
.. configuration-block::
66+
67+
.. code-block:: jinja
68+
69+
{{ form_row(form.password) }}
70+
71+
.. code-block:: php
72+
73+
<?php echo $view['form']->row($form['password']) ?>
74+
75+
個別に各フィールドをレンダリングするためには、このように使用します。:
76+
77+
.. configuration-block::
78+
79+
.. code-block:: jinja
80+
81+
{# .first and .second may vary in your use - see the note below #}
82+
{{ form_row(form.password.first) }}
83+
{{ form_row(form.password.second) }}
84+
85+
.. code-block:: php
86+
87+
<?php echo $view['form']->row($form['password']['first']) ?>
88+
<?php echo $view['form']->row($form['password']['second']) ?>
89+
90+
.. note::
91+
92+
``first`` と ``second`` は二つのサブフィールドのデフォルトの名前です。
93+
しかし、これらの名前は `first_name`_ と `second_name`_ オプションを介して制御することができます。
94+
これらのオプションを設定している場合は、\ ``first`` と ``second`` をレンダリングするとき代わりにそれらの値を使用します。
4995

5096
Validation
5197
~~~~~~~~~~
5298

53-
One of the key features of the ``repeated`` field is internal validation
54-
(you don't need to do anything to set this up) that forces the two fields
55-
to have a matching value. If the two fields don't match, an error will be
56-
shown to the user.
99+
``repeated`` フィールドの主な特徴の一つは(設定するために何もする必要がない)内部検証です。2つのフィールドが一致する値を持つように強制します。
100+
2つのフィールドが一致しない場合、ユーザにエラーが表示されます。
57101

58-
The ``invalid_message`` is used to customize the error that will
59-
be displayed when the two fields do not match each other.
102+
``invalid_message`` は2つのフィールドが一致しないときに表示されるエラーをカスタマイズするために使用されます。
60103

61-
Field Options
62-
-------------
104+
フィールドオプション
105+
--------------------
63106

64107
type
65108
~~~~
66109

67-
**type**: ``string`` **default**: ``text``
110+
**データ型**: ``string`` **デフォルト**: ``text``
68111

69-
The two underlying fields will be of this field type. For example, passing
70-
a type of ``password`` will render two password fields.
112+
その2つのフィールドはこのフィールドタイプになります。たとえば、\ ``password`` タイプを渡すと、二つの ``password`` フィールドをレンダリングします。
71113

72114
options
73115
~~~~~~~
74116

75-
**type**: ``array`` **default**: ``array()``
117+
**データ型**: ``array`` **デフォルト**: ``array()``
76118

77-
This options array will be passed to each of the two underlying fields. In
78-
other words, these are the options that customize the individual field types.
79-
For example, if the ``type`` option is set to ``password``, this array might
80-
contain the options ``always_empty`` or ``required`` - both options that are
81-
supported by the ``password`` field type.
119+
このオプションの配列は二つのフィールドにそれぞれに渡されます。換言すれば、これらは、個々のフィールドタイプをカスタマイズするオプションがあります。
120+
たとえば、\ ``type`` オプションに ``password`` を設定したとき、この配列には ``always_empty`` または ``required`` が含まれるでしょう。
121+
どちらのオプションも ``password`` フィールドタイプでサポートされています。
122+
123+
first_options
124+
~~~~~~~~~~~~~
125+
126+
**データ型**: ``array`` **デフォルト**: ``array()``
127+
128+
第一フィールド *だけ* に渡されるべき追加オプション( `options` にマージされます)です。
129+
これはラベルをカスタマイズする場合に特に便利です。::
130+
131+
$builder->add('password', 'repeated', array(
132+
'first_options' => array('label' => 'Password'),
133+
'second_options' => array('label' => 'Repeat Password'),
134+
));
135+
136+
second_options
137+
~~~~~~~~~~~~~~
138+
139+
**データ型**: ``array`` **デフォルト**: ``array()``
140+
141+
第二フィールド *だけ* に渡されるべき追加オプション( `options` にマージされます)です。
142+
これはラベルをカスタマイズする場合に特に便利です。(参照 `first_options`_ )
82143

83144
first_name
84145
~~~~~~~~~~
85146

86-
**type**: ``string`` **default**: ``first``
147+
**データ型**: ``string`` **デフォルト**: ``first``
87148

88-
This is the actual field name to be used for the first field. This is mostly
89-
meaningless, however, as the actual data entered into both of the fields will
90-
be available under the key assigned to the ``repeated`` field itself (e.g.
91-
``password``). However, if you don't specify a label, this field name is used
92-
to "guess" the label for you.
149+
これは、第一フィールドのために使用される実際のフィールド名です。
150+
大部分には無意味ですが、両方のフィールドに入力された実際のデータは、\ ``repeated`` フィールド自体(例えば``password``)に
151+
割り当てられるそのキーで利用できるようになります。
152+
しかし、ラベルを指定しない場合はこのフィールド名はラベルを「推測」するために使用されます。
93153

94154
second_name
95155
~~~~~~~~~~~
96156

97-
**type**: ``string`` **default**: ``second``
157+
**データ型**: ``string`` **デフォルト**: ``second``
158+
159+
``first_name`` と同様ですが、第二フィールドのためのものです。
160+
161+
上書きされたオプション
162+
----------------------
163+
164+
error_bubbling
165+
~~~~~~~~~~~~~~
98166

99-
The same as ``first_name``, but for the second field.
167+
**デフォルト**: ``false``
100168

101-
Inherited options
102-
-----------------
169+
継承されたオプション
170+
--------------------
103171

104-
These options inherit from the :doc:`field</reference/forms/types/field>` type:
172+
以下のオプションは :doc:`form </reference/forms/types/form>` タイプを継承しています:
173+
174+
.. include:: /reference/forms/types/options/data.rst.inc
105175

106176
.. include:: /reference/forms/types/options/invalid_message.rst.inc
107177

108178
.. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc
109179

110-
.. include:: /reference/forms/types/options/error_bubbling.rst.inc
180+
.. include:: /reference/forms/types/options/mapped.rst.inc
181+
182+
.. include:: /reference/forms/types/options/error_mapping.rst.inc
183+
184+
.. 2014/05/24 yositani2002 d49d12eaf265a5d6d32ac660c62f385d57261475

0 commit comments

Comments
 (0)