Fixes #14368: Added role attribute for active radio list

This commit is contained in:
Evgeniy Moiseenko
2018-09-17 02:26:42 +03:00
committed by Alexander Makarov
parent 1816219067
commit f7862c16c7
3 changed files with 29 additions and 0 deletions

View File

@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.16 under development 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 #16680: Fixed ActiveField 'text' input with maxlength (s1lver)
- Bug #5341: HasMany via two relations (shirase, cebe) - Bug #5341: HasMany via two relations (shirase, cebe)
- Bug #16558: Added cloning `yii\data\ActiveDataProvider::query` property when ActiveDataProvider object is cloned (mgrechanik) - Bug #16558: Added cloning `yii\data\ActiveDataProvider::query` property when ActiveDataProvider object is cloned (mgrechanik)

View File

@ -728,6 +728,7 @@ class ActiveField extends Component
$this->addErrorClassIfNeeded($options); $this->addErrorClassIfNeeded($options);
} }
$this->addRoleAttributes($options, 'radiogroup');
$this->addAriaAttributes($options); $this->addAriaAttributes($options);
$this->adjustLabelFor($options); $this->adjustLabelFor($options);
$this->_skipLabelFor = true; $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. * Adds validation class to the input options if needed.
* @param $options array input options * @param $options array input options

View File

@ -353,6 +353,20 @@ EOD;
$this->assertEqualsWithoutLE($expectedValue, $this->activeField->parts['{input}']); $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() public function testGetClientOptionsReturnEmpty()
{ {
// setup: we want the real deal here! // setup: we want the real deal here!