public function selectText($fieldName, $options = array(), $selected = null, $attributes = array(), $showEmpty = '')
{
$_attributes = array('separator' => '<br />', 'quotes' => true);
$attributes = Hash::merge($_attributes, $attributes);
// $selected、$showEmptyをFormHelperのselect()に対応
$attributes += array('value' => $selected, 'empty' => $showEmpty);
$quotes = $attributes['quotes'];
unset($attributes['quotes']);
$_options = $this->_initInputField($fieldName, $options);
if (empty($attributes['multiple'])) {
$attributes['multiple'] = 'checkbox';
}
$id = $_options['id'];
$_id = $_options['id'] . '_';
$name = $_options['name'];
$out = '<div id="' . $_id . '">' . $this->select($fieldName . '_', $options, $attributes) . '</div>';
$out .= $this->hidden($fieldName);
$script = <<<DOC_END
\$(document).ready(function() {
aryValue = \$("#{$id}").val().replace(/\\'/g,"").split(",");
for(key in aryValue){
var value = aryValue[key];
\$("#"+camelize("{$id}_"+value)).prop('checked',true);
}
\$("#{$_id} input[type=checkbox]").change(function(){
var aryValue = [];
\$("#{$_id} input[type=checkbox]").each(function(key,value){
if(\$(this).prop('checked')){
aryValue.push("'"+\$(this).val()+"'");
}
});
\$("#{$id}").val(aryValue.join(','));
});
});
DOC_END;
$out .= $this->Js->buffer($script);
return $out;
}