Skip to content

[翻訳]reference/forms/types/{checkbox,radio}.rst #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 65 additions & 35 deletions reference/forms/types/checkbox.rst
Original file line number Diff line number Diff line change
@@ -1,58 +1,88 @@
.. index::
single: Forms; Fields; checkbox

checkbox Field Type
===================

Creates a single input checkbox. This should always be used for a field that
has a Boolean value: if the box is checked, the field will be set to true,
if the box is unchecked, the value will be set to false.

+-------------+------------------------------------------------------------------------+
| Rendered as | ``input`` ``text`` field |
+-------------+------------------------------------------------------------------------+
| Options | - `value`_ |
+-------------+------------------------------------------------------------------------+
| Inherited | - `required`_ |
| options | - `label`_ |
| | - `read_only`_ |
| | - `error_bubbling`_ |
+-------------+------------------------------------------------------------------------+
| Parent type | :doc:`field</reference/forms/types/field>` |
+-------------+------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CheckboxType` |
+-------------+------------------------------------------------------------------------+

Example Usage
-------------
.. note::

* 対象バージョン:2.3+
* 翻訳更新日:2014/05/18

checkbox フィールドタイプ
=========================

単一の入力チェックボックスを作成します。これは、常にブール値を持つフィールドに使用する必要があります。
チェックボックスがチェックされている場合 true に設定され、チェックボックスをオフにすると、 false に設定されます。

+------------------+------------------------------------------------------------------------+
| 対応するデータ型 | ``input`` ``checkbox`` フィールド |
+------------------+------------------------------------------------------------------------+
| オプション | - `value`_ |
+------------------+------------------------------------------------------------------------+
| 上書きされた | - `empty_data`_ |
| オプション | - `compound`_ |
+------------------+------------------------------------------------------------------------+
| 継承された | - `data`_ |
| オプション | - `required`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `read_only`_ |
| | - `disabled`_ |
| | - `error_bubbling`_ |
| | - `error_mapping`_ |
| | - `mapped`_ |
+------------------+------------------------------------------------------------------------+
| 親タイプ | :doc:`form </reference/forms/types/form>` |
+------------------+------------------------------------------------------------------------+
| クラス | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CheckboxType` |
+------------------+------------------------------------------------------------------------+

使用例
------

.. code-block:: php

$builder->add('public', 'checkbox', array(
'label' => 'Show this entry publicly?',
'label' => 'このエントリーを公開しますか?',
'required' => false,
));

Field Options
-------------
フィールドオプション
--------------------

value
~~~~~
.. include:: /reference/forms/types/options/value.rst.inc

**type**: ``mixed`` **default**: ``1``
上書きされたオプション
----------------------

The value that's actually used as the value for the checkbox. This does
not affect the value that's set on your object.
.. include:: /reference/forms/types/options/checkbox_empty_data.rst.inc

Inherited options
-----------------
.. include:: /reference/forms/types/options/checkbox_compound.rst.inc

These options inherit from the :doc:`field</reference/forms/types/field>` type:
継承されたオプション
--------------------

以下のオプションは :doc:`form </reference/forms/types/form>` タイプを継承しています:

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

.. include:: /reference/forms/types/options/required.rst.inc

.. include:: /reference/forms/types/options/label.rst.inc

.. include:: /reference/forms/types/options/label_attr.rst.inc

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

.. include:: /reference/forms/types/options/disabled.rst.inc

.. include:: /reference/forms/types/options/error_bubbling.rst.inc

.. include:: /reference/forms/types/options/error_mapping.rst.inc

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

フォーム変数
------------

.. include:: /reference/forms/types/variables/check_or_radio_table.rst.inc

.. 2014/05/18 yositani2002 d49d12eaf265a5d6d32ac660c62f385d57261475
9 changes: 9 additions & 0 deletions reference/forms/types/options/checkbox_compound.rst.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
compound
~~~~~~~~

**データ型**: ``boolean`` **デフォルト**: ``false``

このオプションは、フォームが合成物であるかを指定します。
チェックボックスの場合は該当しないため、デフォルトの値を ``false`` で上書きします。

.. 2014/05/18 yositani2002 8d4f444c25ba45439bef046bda1b1abb89c84ed0
9 changes: 9 additions & 0 deletions reference/forms/types/options/checkbox_empty_data.rst.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
empty_data
~~~~~~~~~~

**データ型**: ``string`` **デフォルト**: ``mixed``

このオプションでは、\ ``empty_value`` 選択肢が選択されたときにどのような値を返すかを決定します。
チェックボックスでは、\ ``empty_data`` の値はデータトランスフォーマー(参照 :doc:`/cookbook/form/data_transformers`) によって返された値で上書きされます。

.. 2014/05/18 yositani2002 64602c83849b29088bfbf60b46a8fb802bcc9860
3 changes: 2 additions & 1 deletion reference/forms/types/options/label_attr.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ label_attr
array('label_attr' => array('class' => 'CUSTOM_LABEL_CLASS'))
);

.. 2014/05/10 yositani2002 82c1db5644d1373f000e8e8dc1a3624b010faeef
.. 2014/05/18 yositani2002 82c1db5644d1373f000e8e8dc1a3624b010faeef

13 changes: 13 additions & 0 deletions reference/forms/types/options/value.rst.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
value
~~~~~

**データ型**: ``mixed`` **デフォルト**: ``1``

実際にチェックボックスやラジオボタンの値として使われていた値です。
これはオブジェクトにセットする値には影響しません。

.. caution::

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

.. 2014/05/18 yositani2002 322b21e191c19d2c2d6a83f92762f72a5122b742
85 changes: 53 additions & 32 deletions reference/forms/types/radio.rst
Original file line number Diff line number Diff line change
@@ -1,52 +1,73 @@
.. index::
single: Forms; Fields; radio

radio Field Type
================
.. note::

Creates a single radio button. This should always be used for a field that
has a Boolean value: if the radio button is selected, the field will be set
to true, if the button is not selected, the value will be set to false.
* 対象バージョン:2.3+
* 翻訳更新日:2014/05/18

The ``radio`` type isn't usually used directly. More commonly it's used
internally by other types such as :doc:`choice</reference/forms/types/choice>`.
If you want to have a Boolean field, use :doc:`checkbox</reference/forms/types/checkbox>`.
radio フィールドタイプ
======================

+-------------+---------------------------------------------------------------------+
| Rendered as | ``input`` ``text`` field |
+-------------+---------------------------------------------------------------------+
| Options | - `value`_ |
+-------------+---------------------------------------------------------------------+
| Inherited | - `required`_ |
| options | - `label`_ |
| | - `read_only`_ |
| | - `error_bubbling`_ |
+-------------+---------------------------------------------------------------------+
| Parent type | :doc:`field</reference/forms/types/field>` |
+-------------+---------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RadioType` |
+-------------+---------------------------------------------------------------------+
シングルラジオボタンを作成します。ラジオボタンを選択した場合は、フィールドは指定された値に設定されます。
ラジオボタンはチェックをはずすことはできません - 値は、同じ名前で別のラジオボタンがチェックされるときに変更されます。

Field Options
-------------
``radio`` 型は、通常は直接使用することはありません。
一般的に、 :doc:`choice </reference/forms/types/choice>` のようなほかのタイプの内部で使われます。
``Boolean`` フィールドを使用したい場合は :doc:`checkbox </reference/forms/types/checkbox>` を使用してください。

value
~~~~~
+------------------+---------------------------------------------------------------------+
| 対応するデータ型 | ``input`` ``radio`` フィールド |
+------------------+---------------------------------------------------------------------+
| 継承された | - `value`_ |
| オプション | - `data`_ |
| | - `empty_data`_ |
| | - `required`_ |
| | - `label`_ |
| | - `label_attr`_ |
| | - `read_only`_ |
| | - `disabled`_ |
| | - `error_bubbling`_ |
| | - `error_mapping`_ |
| | - `mapped`_ |
+------------------+---------------------------------------------------------------------+
| 親タイプ | :doc:`checkbox </reference/forms/types/checkbox>` |
+------------------+---------------------------------------------------------------------+
| クラス | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RadioType` |
+------------------+---------------------------------------------------------------------+

**type**: ``mixed`` **default**: ``1``
継承されたオプション
--------------------

The value that's actually used as the value for the radio button. This does
not affect the value that's set on your object.
以下のオプションは :doc:`checkbox </reference/forms/types/checkbox>` タイプを継承しています:

Inherited Options
-----------------
.. include:: /reference/forms/types/options/value.rst.inc

These options inherit from the :doc:`field</reference/forms/types/field>` type:
以下のオプションは :doc:`form </reference/forms/types/form>` タイプを継承しています:

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

.. include:: /reference/forms/types/options/empty_data.rst.inc

.. include:: /reference/forms/types/options/required.rst.inc

.. include:: /reference/forms/types/options/label.rst.inc

.. include:: /reference/forms/types/options/label_attr.rst.inc

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

.. include:: /reference/forms/types/options/disabled.rst.inc

.. include:: /reference/forms/types/options/error_bubbling.rst.inc

.. include:: /reference/forms/types/options/error_mapping.rst.inc

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

フォーム変数
------------

.. include:: /reference/forms/types/variables/check_or_radio_table.rst.inc

.. 2014/05/18 yositani2002 490633b97f8c2931bc43a76dd060cfcc50da432d
7 changes: 7 additions & 0 deletions reference/forms/types/variables/check_or_radio_table.rst.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
======== ============ ============================================
変数 データ型 使い方
======== ============ ============================================
checked ``Boolean`` 現在の入力がチェックされているかどうか。
======== ============ ============================================

.. 2014/05/18 yositani2002 1a1497c1b296cc0711d486b1a8925d029baa8e8f