Skip to content
Permalink
Browse files

Convert Radio to use selected instead of value.

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 88100a4bb7ee56b074b76f2ef4f579786a192dd9
Showing with 4 additions and 4 deletions.
  1. +3 −3 src/View/Input/Radio.php
  2. +1 −1 tests/TestCase/View/Input/RadioTest.php
@@ -61,7 +61,7 @@ public function __construct($templates) {
* - `options` - An array of options. See below for more information.
* - `disabled` - Either true or an array of inputs to disable.
* 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
* an array of attributes for all labels.
*
@@ -73,7 +73,7 @@ public function render($data) {
'name' => '',
'options' => [],
'disabled' => null,
'value' => null,
'selected' => null,
'escape' => true,
'label' => true,
'empty' => false,
@@ -137,7 +137,7 @@ protected function _renderInput($val, $text, $data) {
$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;
}
@@ -215,7 +215,7 @@ public function testRenderSelected() {
$radio = new Radio($this->templates);
$data = [
'name' => 'Versions[ver]',
'value' => '1',
'selected' => '1',
'options' => [
1 => 'one',
'1x' => 'one x',

0 comments on commit 88100a4

Please sign in to comment.
You can’t perform that action at this time.