mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge remote-tracking branch 'origin/2.0' into 2.0-class-loading
This commit is contained in:
commit
2e2f5ea2a5
4 changed files with 40 additions and 2 deletions
|
@ -1041,6 +1041,7 @@ class FormHelper extends AppHelper {
|
|||
public function radio($fieldName, $options = array(), $attributes = array()) {
|
||||
$attributes = $this->_initInputField($fieldName, $attributes);
|
||||
$legend = false;
|
||||
$disabled = array();
|
||||
|
||||
if (isset($attributes['legend'])) {
|
||||
$legend = $attributes['legend'];
|
||||
|
@ -1066,6 +1067,11 @@ class FormHelper extends AppHelper {
|
|||
} else {
|
||||
$value = $this->value($fieldName);
|
||||
}
|
||||
|
||||
if (isset($attributes['disabled'])) {
|
||||
$disabled = $attributes['disabled'];
|
||||
}
|
||||
|
||||
$out = array();
|
||||
|
||||
$hiddenField = isset($attributes['hiddenField']) ? $attributes['hiddenField'] : true;
|
||||
|
@ -1077,6 +1083,9 @@ class FormHelper extends AppHelper {
|
|||
if (isset($value) && $optValue == $value) {
|
||||
$optionsHere['checked'] = 'checked';
|
||||
}
|
||||
if (!empty($disabled) && in_array($optValue, $disabled)) {
|
||||
$optionsHere['disabled'] = true;
|
||||
}
|
||||
$tagName = Inflector::camelize(
|
||||
$attributes['id'] . '_' . Inflector::slug($optValue)
|
||||
);
|
||||
|
|
|
@ -307,7 +307,7 @@ class CacheTest extends CakeTestCase {
|
|||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||
), true);
|
||||
|
||||
Cache::config('test_trigger', array('engine' => 'TestAppCache'));
|
||||
Cache::config('test_trigger', array('engine' => 'TestAppCache', 'prefix' => ''));
|
||||
try {
|
||||
Cache::write('fail', 'value', 'test_trigger');
|
||||
$this->fail('No exception thrown');
|
||||
|
|
|
@ -3018,6 +3018,35 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* test disabled radio options
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testRadioDisabled() {
|
||||
$result = $this->Form->radio(
|
||||
'Model.field',
|
||||
array('option A', 'option B'),
|
||||
array('disabled' => array('option A'), 'value' => 'option A')
|
||||
);
|
||||
$expected = array(
|
||||
'fieldset' => array(),
|
||||
'legend' => array(),
|
||||
'Field',
|
||||
'/legend',
|
||||
array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField0', 'disabled' => 'disabled', 'checked' => 'checked')),
|
||||
array('label' => array('for' => 'ModelField0')),
|
||||
'option A',
|
||||
'/label',
|
||||
array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField1')),
|
||||
array('label' => array('for' => 'ModelField1')),
|
||||
'option B',
|
||||
'/label',
|
||||
'/fieldset'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* test disabling the hidden input for radio buttons
|
||||
*
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
class TestAppCacheEngine extends CacheEngine {
|
||||
|
||||
public function write($key, $value, $duration) {
|
||||
if ($key = 'fail') {
|
||||
if ($key == 'fail') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue