refs #6635 FormHelper::radio() return collect id attributes with multibyte

This commit is contained in:
nojimage 2015-05-25 22:10:50 +09:00
parent 15f88533e8
commit 8ebc9cdd87
2 changed files with 25 additions and 1 deletions

View file

@ -3902,6 +3902,25 @@ class FormHelperTest extends CakeTestCase {
'/fieldset' '/fieldset'
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
$result = $this->Form->radio(
'Model.multibyte',
array('男性' => '男性')
);
$expected = array(
'input' => array(
'type' => 'hidden', 'name' => 'data[Model][multibyte]',
'id' => 'ModelMultibyte_', 'value' => '',
),
array('input' => array(
'type' => 'radio', 'name' => 'data[Model][multibyte]',
'id' => 'ModelMultibyte男性', 'value' => '男性')
),
array('label' => array('for' => 'ModelMultibyte男性')),
'男性',
'/label',
);
$this->assertTags($result, $expected);
} }
/** /**

View file

@ -495,7 +495,12 @@ class Inflector {
*/ */
public static function humanize($lowerCaseAndUnderscoredWord) { public static function humanize($lowerCaseAndUnderscoredWord) {
if (!($result = self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { if (!($result = self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) {
$result = ucwords(str_replace('_', ' ', $lowerCaseAndUnderscoredWord)); $result = str_replace('_', ' ', $lowerCaseAndUnderscoredWord);
if (function_exists('mb_convert_case') && Multibyte::checkMultibyte($result)) {
$result = mb_convert_case($result, MB_CASE_TITLE, Configure::read('App.encoding'));
} else {
$result = ucwords($result);
}
self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result); self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result);
} }
return $result; return $result;