Skip to content

Commit

Permalink
Adding some missing documentation and cleaning up code inside FormHel…
Browse files Browse the repository at this point in the history
…per::select().
  • Loading branch information
markstory committed Oct 16, 2010
1 parent c35ef7d commit 61864a3
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions cake/libs/view/helpers/form.php
Expand Up @@ -1381,6 +1381,7 @@ function submit($caption = null, $options = array()) {
* - `empty` - If true, the empty select option is shown. If a string,
* that string is displayed as the empty element.
* - `escape` - If true contents of options will be HTML entity encoded. Defaults to true.
* - `class` - When using multiple = checkbox the classname to apply to the divs. Defaults to 'checkbox'.
*
* ### Using options
*
Expand Down Expand Up @@ -1418,27 +1419,25 @@ function submit($caption = null, $options = array()) {
*/
function select($fieldName, $options = array(), $selected = null, $attributes = array()) {
$select = array();
$showParents = false;
$escapeOptions = true;
$style = null;
$tag = null;
$showEmpty = '';
$attributes += array(
'class' => null,
'escape' => true,
'secure' => null,
'empty' => '',
'showParents' => false
);

$escapeOptions = $this->_extractOption('escape', $attributes);
$secure = $this->_extractOption('secure', $attributes);
$showEmpty = $this->_extractOption('empty', $attributes);
$showParents = $this->_extractOption('showParents', $attributes);
unset($attributes['escape'], $attributes['secure'], $attributes['empty'], $attributes['showParents']);

if (isset($attributes['escape'])) {
$escapeOptions = $attributes['escape'];
unset($attributes['escape']);
}
if (isset($attributes['secure'])) {
$secure = $attributes['secure'];
}
if (isset($attributes['empty'])) {
$showEmpty = $attributes['empty'];
unset($attributes['empty']);
}
$attributes = $this->_initInputField($fieldName, array_merge(
(array)$attributes, array('secure' => false)
));
$attributes += array('class' => null);

if (is_string($options) && isset($this->__options[$options])) {
$options = $this->__generateOptions($options);
Expand All @@ -1448,10 +1447,6 @@ function select($fieldName, $options = array(), $selected = null, $attributes =
if (isset($attributes['type'])) {
unset($attributes['type']);
}
if (in_array('showParents', $attributes)) {
$showParents = true;
unset($attributes['showParents']);
}

if (!isset($selected)) {
$selected = $attributes['value'];
Expand Down

0 comments on commit 61864a3

Please sign in to comment.