mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 22:32:40 +08:00
Fixes #14368: Added role attribute for active radio list
This commit is contained in:
committed by
Alexander Makarov
parent
1816219067
commit
f7862c16c7
@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
||||
2.0.16 under development
|
||||
------------------------
|
||||
|
||||
- Bug #14368: Added `role` attribute for active radio list (s1lver)
|
||||
- Bug #16680: Fixed ActiveField 'text' input with maxlength (s1lver)
|
||||
- Bug #5341: HasMany via two relations (shirase, cebe)
|
||||
- Bug #16558: Added cloning `yii\data\ActiveDataProvider::query` property when ActiveDataProvider object is cloned (mgrechanik)
|
||||
|
||||
@ -728,6 +728,7 @@ class ActiveField extends Component
|
||||
$this->addErrorClassIfNeeded($options);
|
||||
}
|
||||
|
||||
$this->addRoleAttributes($options, 'radiogroup');
|
||||
$this->addAriaAttributes($options);
|
||||
$this->adjustLabelFor($options);
|
||||
$this->_skipLabelFor = true;
|
||||
@ -923,6 +924,19 @@ class ActiveField extends Component
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add role attributes to the input options
|
||||
* @param $options array input options
|
||||
* @param string $role
|
||||
* @since 2.0.16
|
||||
*/
|
||||
protected function addRoleAttributes(&$options, $role)
|
||||
{
|
||||
if (!isset($options['role'])) {
|
||||
$options['role'] = $role;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds validation class to the input options if needed.
|
||||
* @param $options array input options
|
||||
|
||||
@ -353,6 +353,20 @@ EOD;
|
||||
$this->assertEqualsWithoutLE($expectedValue, $this->activeField->parts['{input}']);
|
||||
}
|
||||
|
||||
public function testRadioList()
|
||||
{
|
||||
$expectedValue = <<<'EOD'
|
||||
<div class="form-group field-activefieldtestmodel-attributename">
|
||||
<label class="control-label">Attribute Name</label>
|
||||
<input type="hidden" name="ActiveFieldTestModel[attributeName]" value=""><div id="activefieldtestmodel-attributename" role="radiogroup"><label><input type="radio" name="ActiveFieldTestModel[attributeName]" value="1"> Item One</label></div>
|
||||
<div class="hint-block">Hint for attributeName attribute</div>
|
||||
<div class="help-block"></div>
|
||||
</div>
|
||||
EOD;
|
||||
$this->activeField->radioList(['1' => 'Item One']);
|
||||
$this->assertEqualsWithoutLE($expectedValue, $this->activeField->render());
|
||||
}
|
||||
|
||||
public function testGetClientOptionsReturnEmpty()
|
||||
{
|
||||
// setup: we want the real deal here!
|
||||
|
||||
Reference in New Issue
Block a user