Skip to content
Snippets Groups Projects
Commit ce0758a5 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

Merge pull request #1361 from TorMec/master

multicheckbox without extra string input
parents 54c0fa7c 77446daa
No related branches found
No related tags found
No related merge requests found
......@@ -1191,6 +1191,7 @@ if (!class_exists('setting_multicheckbox')) {
var $_choices = array();
var $_combine = array();
var $_other = 'always';
/**
* update changed setting with user provided value $input
......@@ -1274,16 +1275,21 @@ if (!class_exists('setting_multicheckbox')) {
}
// handle any remaining values
$other = join(',',$value);
$class = ((count($default) == count($value)) && (count($value) == count(array_intersect($value,$default)))) ?
" selectiondefault" : "";
$input .= '<div class="other'.$class.'">'."\n";
$input .= '<label for="config___'.$key.'_other">'.$plugin->getLang($key.'_other')."</label>\n";
$input .= '<input id="config___'.$key.'_other" name="config['.$key.'][other]" type="text" class="edit" value="'.htmlspecialchars($other).'" '.$disable." />\n";
$input .= "</div>\n";
if ($this->_other != 'never'){
$other = join(',',$value);
// test equivalent to ($this->_other == 'always' || ($other && $this->_other == 'exists')
// use != 'exists' rather than == 'always' to ensure invalid values default to 'always'
if ($this->_other != 'exists' || $other) {
$class = ((count($default) == count($value)) && (count($value) == count(array_intersect($value,$default)))) ?
" selectiondefault" : "";
$input .= '<div class="other'.$class.'">'."\n";
$input .= '<label for="config___'.$key.'_other">'.$plugin->getLang($key.'_other')."</label>\n";
$input .= '<input id="config___'.$key.'_other" name="config['.$key.'][other]" type="text" class="edit" value="'.htmlspecialchars($other).'" '.$disable." />\n";
$input .= "</div>\n";
}
}
$label = '<label>'.$this->prompt($plugin).'</label>';
return array($label,$input);
}
......
......@@ -70,6 +70,12 @@
* '_pregflags' - string, default 'ui', valid preg pattern modifiers used when testing regex input values, for more
* information see http://uk1.php.net/manual/en/reference.pcre.pattern.modifiers.php
* '_multiple' - bool, allow multiple comma separated email values; optional for 'email', ignored by others
* '_other' - how to handle other values (not listed in _choices). accepted values: 'always','exists','never'
* default value 'always'. 'exists' only shows 'other' input field when the setting contains value(s)
* not listed in choices (e.g. due to manual editing or update changing _choices). This is safer than
* 'never' as it will not discard unknown/other values.
* optional for 'multicheckbox', ignored by others
*
*
* @author Chris Smith <chris@jalakai.co.uk>
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment