Skip to content

Commit

Permalink
Convert Radio to use selected instead of value.
Browse files Browse the repository at this point in the history
Having consistency between components is important at this stage,
and will be important later as well. Value is harder to use as it over
laps with checkbox values.
  • Loading branch information
markstory committed Jan 12, 2014
1 parent 3d33cdc commit 88100a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/View/Input/Radio.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct($templates) {
* - `options` - An array of options. See below for more information. * - `options` - An array of options. See below for more information.
* - `disabled` - Either true or an array of inputs to disable. * - `disabled` - Either true or an array of inputs to disable.
* When true, the select element will be disabled. * When true, the select element will be disabled.
* - `value` - A string of the option to mark as selected. * - `selected` - A string of the option to mark as selected.
* - `label` - Either false to disable label generation, or * - `label` - Either false to disable label generation, or
* an array of attributes for all labels. * an array of attributes for all labels.
* *
Expand All @@ -73,7 +73,7 @@ public function render($data) {
'name' => '', 'name' => '',
'options' => [], 'options' => [],
'disabled' => null, 'disabled' => null,
'value' => null, 'selected' => null,
'escape' => true, 'escape' => true,
'label' => true, 'label' => true,
'empty' => false, 'empty' => false,
Expand Down Expand Up @@ -137,7 +137,7 @@ protected function _renderInput($val, $text, $data) {
$radio['id'] = Inflector::slug($radio['name'] . '_' . $radio['value']); $radio['id'] = Inflector::slug($radio['name'] . '_' . $radio['value']);
} }


if (isset($data['value']) && strval($data['value']) === strval($radio['value'])) { if (isset($data['selected']) && strval($data['selected']) === strval($radio['value'])) {
$radio['checked'] = true; $radio['checked'] = true;
} }


Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/View/Input/RadioTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public function testRenderSelected() {
$radio = new Radio($this->templates); $radio = new Radio($this->templates);
$data = [ $data = [
'name' => 'Versions[ver]', 'name' => 'Versions[ver]',
'value' => '1', 'selected' => '1',
'options' => [ 'options' => [
1 => 'one', 1 => 'one',
'1x' => 'one x', '1x' => 'one x',
Expand Down

0 comments on commit 88100a4

Please sign in to comment.