diff --git a/Croogo/Test/Case/View/Helper/CroogoFormHelperTest.php b/Croogo/Test/Case/View/Helper/CroogoFormHelperTest.php index 6dbaaad903..98a23135e2 100644 --- a/Croogo/Test/Case/View/Helper/CroogoFormHelperTest.php +++ b/Croogo/Test/Case/View/Helper/CroogoFormHelperTest.php @@ -494,4 +494,32 @@ public function testInputPlaceholderNestedModel() { $this->assertTags($result, $expected); } +/** + * Test radio button class + */ + public function testInputRadioButtonClass() { + $result = $this->CroogoForm->input('Node.promote', array( + 'type' => 'radio', + 'class' => 'super-radio-button', + 'options' => array( + 0 => 'Not promoted', + 1 => 'Promoted', + ), + )); + $this->assertStringStartsWith('
', $result); + $this->assertContains('class="super-radio-button"', $result); + } + +/** + * Test checkbox class + */ + public function testInputCheckboxClass() { + $result = $this->CroogoForm->input('Node.promote', array( + 'type' => 'checkbox', + 'class' => 'super-checkbox-button', + )); + $this->assertStringStartsWith('
', $result); + $this->assertContains('class="super-checkbox-button"', $result); + } + } diff --git a/Croogo/View/Helper/CroogoFormHelper.php b/Croogo/View/Helper/CroogoFormHelper.php index 3c83148453..382bea20c4 100644 --- a/Croogo/View/Helper/CroogoFormHelper.php +++ b/Croogo/View/Helper/CroogoFormHelper.php @@ -158,15 +158,25 @@ protected function _parseOptions($options) { $options = parent::_parseOptions($options); $options = $this->_parseOptionsAddon($options); - if (isset($options['class'])) { - $formInput = $this->Theme->getCssClass('formInput'); - $isMultipleCheckbox = isset($options['multiple']) && - $options['multiple'] === 'checkbox'; - $isRadioOrCheckbox = isset($options['type']) && - in_array($options['type'], array('checkbox', 'radio')); - - if ($isMultipleCheckbox || $isRadioOrCheckbox) { - $options['class'] = str_replace($formInput, '', $options['class']); + $formInput = $this->Theme->getCssClass('formInput'); + $isMultipleCheckbox = isset($options['multiple']) && + $options['multiple'] === 'checkbox'; + $isRadioOrCheckbox = isset($options['type']) && + in_array($options['type'], array('checkbox', 'radio')); + + if ($isMultipleCheckbox || $isRadioOrCheckbox) { + if ($options['type'] == 'radio') { + $class = $this->Theme->getCssClass('radioClass'); + } elseif ($options['type'] == 'checkbox') { + $class = $this->Theme->getCssClass('checkboxClass'); + } + if (empty($class) && isset($options['class'])) { + $class = str_replace($formInput, '', $options['class']); + } + if (empty($class)) { + unset($options['class']); + } else { + $options['class'] = $class; } } diff --git a/Extensions/Lib/CroogoTheme.php b/Extensions/Lib/CroogoTheme.php index 614fda0e54..100ceb10a7 100644 --- a/Extensions/Lib/CroogoTheme.php +++ b/Extensions/Lib/CroogoTheme.php @@ -287,7 +287,17 @@ public static function config($theme = null) { } if (empty($themeData[$theme])) { - $themeData[$theme] = $croogoTheme->getData($theme); + $data = $croogoTheme->getData($theme); + $request = Router::getRequest(); + if ($request) { + $prefix = $request->param('prefix'); + if (isset($data['settings']['prefixes'][$prefix]['css'])) { + $data['settings']['css'] = Hash::merge($data['settings']['prefixes'][$prefix]['css'], + $data['settings']['css'] + ); + } + } + $themeData[$theme] = $data; } return $themeData[$theme];