public function select($fieldName, $options = array(), $attributes = array())
{
$select = array();
$style = null;
$tag = null;
$attributes += array('class' => null, 'escape' => true, 'secure' => true, 'empty' => '', 'showParents' => false, 'hiddenField' => true, 'disabled' => false, 'div' => true);
// CUSTOMIZE ADD 2016/01/28 ryuring
// checkboxのdivを外せるオプションを追加
// >>>
$div = $this->_extractOption('div', $attributes);
unset($attributes['div']);
// <<<
$escapeOptions = $this->_extractOption('escape', $attributes);
$secure = $this->_extractOption('secure', $attributes);
$showEmpty = $this->_extractOption('empty', $attributes);
$showParents = $this->_extractOption('showParents', $attributes);
$hiddenField = $this->_extractOption('hiddenField', $attributes);
unset($attributes['escape'], $attributes['secure'], $attributes['empty'], $attributes['showParents'], $attributes['hiddenField']);
$id = $this->_extractOption('id', $attributes);
$attributes = $this->_initInputField($fieldName, array_merge((array) $attributes, array('secure' => static::SECURE_SKIP)));
if (is_string($options) && isset($this->_options[$options])) {
$options = $this->_generateOptions($options);
} elseif (!is_array($options)) {
$options = array();
}
if (isset($attributes['type'])) {
unset($attributes['type']);
}
if (!empty($attributes['multiple'])) {
$style = $attributes['multiple'] === 'checkbox' ? 'checkbox' : null;
$template = $style ? 'checkboxmultiplestart' : 'selectmultiplestart';
$tag = $template;
if ($hiddenField) {
$hiddenAttributes = array('value' => '', 'id' => $attributes['id'] . ($style ? '' : '_'), 'secure' => false, 'form' => isset($attributes['form']) ? $attributes['form'] : null, 'name' => $attributes['name'], 'disabled' => $attributes['disabled'] === true || $attributes['disabled'] === 'disabled');
$select[] = $this->hidden(null, $hiddenAttributes);
}
} else {
$tag = 'selectstart';
}
if ($tag === 'checkboxmultiplestart') {
unset($attributes['required']);
}
if (!empty($tag) || isset($template)) {
$hasOptions = count($options) > 0 || $showEmpty;
// Secure the field if there are options, or its a multi select.
// Single selects with no options don't submit, but multiselects do.
if ((!isset($secure) || $secure) && empty($attributes['disabled']) && (!empty($attributes['multiple']) || $hasOptions)) {
$this->_secure(true, $this->_secureFieldName($attributes));
}
$filter = array('name' => null, 'value' => null);
if (is_array($attributes['disabled'])) {
$filter['disabled'] = null;
}
$select[] = $this->Html->useTag($tag, $attributes['name'], array_diff_key($attributes, $filter));
}
$emptyMulti = $showEmpty !== null && $showEmpty !== false && !(empty($showEmpty) && (isset($attributes) && array_key_exists('multiple', $attributes)));
if ($emptyMulti) {
$showEmpty = $showEmpty === true ? '' : $showEmpty;
$options = array('' => $showEmpty) + $options;
}
if (!$id) {
$attributes['id'] = Inflector::camelize($attributes['id']);
}
$select = array_merge($select, $this->_selectOptions(array_reverse($options, true), array(), $showParents, array('escape' => $escapeOptions, 'style' => $style, 'name' => $attributes['name'], 'value' => $attributes['value'], 'class' => $attributes['class'], 'id' => $attributes['id'], 'disabled' => $attributes['disabled'], 'div' => $div)));
$template = $style === 'checkbox' ? 'checkboxmultipleend' : 'selectend';
$select[] = $this->Html->useTag($template);
return implode("\n", $select);
}