1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 14:46:56 +02:00

Issue #3202 uc_select() was not respecting default value.

This commit is contained in:
Cameron
2019-03-01 11:12:54 -08:00
parent 8e5fd33494
commit a457863c56
2 changed files with 31 additions and 13 deletions

View File

@@ -90,9 +90,9 @@ e107::coreLan('userclass2', true);
'userclass_description' => array('title'=> LAN_DESCRIPTION, 'type' => 'text', 'tab'=>0,'data'=>'str', 'inline'=>true,'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array('size'=>'xxlarge')),
'userclass_type' => array('title'=> LAN_TYPE, 'type' => 'dropdown', 'tab'=>0,'data'=>'int', 'width' => '10%', 'thclass' => 'left', 'class'=>'left' ),
'userclass_editclass' => array('title'=> LAN_MANAGER, 'type' => 'userclass', 'tab'=>0,'data'=>'int', 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array('classlist'=>'nobody,public,main,admin,classes,matchclass,member, no-excludes')),
'userclass_visibility' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'tab'=>0,'data'=>'int', 'width' => 'auto', 'thclass' => 'left'),
'userclass_visibility' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'tab'=>0,'data'=>'int', 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array()),
'userclass_parent' => array('title'=> LAN_PARENT, 'type' => 'userclass', 'tab'=>0,'data'=>'int', 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array('classlist'=>'main,admin,nobody,public,classes,matchclass,member, no-excludes')),
'userclass_perms' => array('title'=> "Perms", 'type' => 'hidden', 'tab'=>0,'data'=>'str', 'width' => 'auto', 'thclass' => 'left'),
'userclass_perms' => array('title'=> "Perms", 'type' => 'hidden', 'tab'=>0,'data'=>'str', 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>array()),
'options' => array('title'=> LAN_OPTIONS, 'type' => 'method', 'width' => '10%', 'thclass' => 'center last', 'forced'=>TRUE, 'class'=>'right', 'readParms' => array('deleteClass' => e_UC_NOBODY))
);

View File

@@ -3147,26 +3147,40 @@ class e_form
</span>
*/
}
}
function uc_select($name, $current_value, $uc_options, $select_options = array(), $opt_options = array())
/**
* @param $name
* @param null $current_value
* @param null $uc_options
* @param array $select_options multiple, default
* @param array $opt_options
* @return string
*/
function uc_select($name, $current_value=null, $uc_options=null, $select_options = array(), $opt_options = array())
{
/* var_dump($name);
var_dump($current_value);
var_dump($uc_options);
var_dump($select_options);*/
if(!empty($select_options['multiple']) && substr($name,-1) != ']')
{
$name .= '[]';
}
if(empty($current_value) && !empty($uc_options)) // make the first in the opt list the default value.
if(($current_value === null || $current_value === '') && !empty($uc_options)) // make the first in the opt list the default value.
{
$tmp = explode(",", $uc_options);
$current_value = e107::getUserClass()->getClassFromKey($tmp[0]);
if(isset($select_options['default']))
{
$current_value = (int) $select_options['default'];
}
}
if(!empty($current_value) && !is_numeric($current_value)) // convert name to id.
@@ -3189,7 +3203,11 @@ class e_form
unset($tmp);
}
return $this->select_open($name, $select_options)."\n".$this->_uc->vetted_tree($name, array($this, '_uc_select_cb'), $current_value, $uc_options, $opt_options)."\n".$this->select_close();
$text = $this->select_open($name, $select_options)."\n";
$text .= $this->_uc->vetted_tree($name, array($this, '_uc_select_cb'), $current_value, $uc_options, $opt_options)."\n";
$text .= $this->select_close();
return $text;
}
// Callback for vetted_tree - Creates the option list for a selection box
@@ -5720,7 +5738,7 @@ class e_form
$parms['post'] = "<small class='e-tip admin-multilanguage-field input-group-addon' style='cursor:help; padding-left:10px' title='".LAN_EFORM_012." (".e_LANGUAGE.")'>".$tp->toGlyph('fa-language')."</small>".varset($parms['post']);
$key = $key.'['.e_LANGUAGE.']';
}
if(empty($value) && !empty($parms['default']) && $attributes['type'] !== 'dropdown') // Allow writeParms to set default value.
{
$value = $parms['default'];