Fix: Test sur user assigned not filled
Can use empty line into select boolean form.
This commit is contained in:
parent
a4a01de8a1
commit
b6b6cced30
@ -251,11 +251,11 @@ if ($action == 'add')
|
|||||||
if (! empty($conf->phenix->enabled) && GETPOST('add_phenix') == 'on') $object->use_phenix=1;
|
if (! empty($conf->phenix->enabled) && GETPOST('add_phenix') == 'on') $object->use_phenix=1;
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (empty($object->userownerid))
|
if (empty($object->userownerid) && empty($_SESSION['assignedtouser']))
|
||||||
{
|
{
|
||||||
$error++; $donotclearsession=1;
|
$error++; $donotclearsession=1;
|
||||||
$action = 'create';
|
$action = 'create';
|
||||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ActionAffectedTo")), 'errors');
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ActionsOwnedBy")), 'errors');
|
||||||
}
|
}
|
||||||
if ($object->type_code == 'AC_RDV' && ($datep == '' || ($datef == '' && empty($fulldayevent))))
|
if ($object->type_code == 'AC_RDV' && ($datep == '' || ($datef == '' && empty($fulldayevent))))
|
||||||
{
|
{
|
||||||
@ -423,7 +423,7 @@ if ($action == 'update')
|
|||||||
{
|
{
|
||||||
$error++; $donotclearsession=1;
|
$error++; $donotclearsession=1;
|
||||||
$action = 'edit';
|
$action = 'edit';
|
||||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ActionAffectedTo")), 'errors');
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ActionsOwnedBy")), 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
|
|||||||
@ -4170,14 +4170,14 @@ class Form
|
|||||||
* @param string $value Pre-selected value
|
* @param string $value Pre-selected value
|
||||||
* @param int $option 0 return yes/no, 1 return 1/0
|
* @param int $option 0 return yes/no, 1 return 1/0
|
||||||
* @param bool $disabled true or false
|
* @param bool $disabled true or false
|
||||||
|
* @param useempty $useempty 1=Add empty line
|
||||||
* @return mixed See option
|
* @return mixed See option
|
||||||
*/
|
*/
|
||||||
function selectyesno($htmlname,$value='',$option=0,$disabled=false)
|
function selectyesno($htmlname,$value='',$option=0,$disabled=false,$useempty='')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$yes="yes"; $no="no";
|
$yes="yes"; $no="no";
|
||||||
|
|
||||||
if ($option)
|
if ($option)
|
||||||
{
|
{
|
||||||
$yes="1";
|
$yes="1";
|
||||||
@ -4187,6 +4187,7 @@ class Form
|
|||||||
$disabled = ($disabled ? ' disabled="disabled"' : '');
|
$disabled = ($disabled ? ' disabled="disabled"' : '');
|
||||||
|
|
||||||
$resultyesno = '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.$disabled.'>'."\n";
|
$resultyesno = '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.$disabled.'>'."\n";
|
||||||
|
if ($useempty) $resultyesno .= '<option value="-1"'.(($value < 0)?' selected="selected"':'').'></option>'."\n";
|
||||||
if (("$value" == 'yes') || ($value == 1))
|
if (("$value" == 'yes') || ($value == 1))
|
||||||
{
|
{
|
||||||
$resultyesno .= '<option value="'.$yes.'" selected="selected">'.$langs->trans("Yes").'</option>'."\n";
|
$resultyesno .= '<option value="'.$yes.'" selected="selected">'.$langs->trans("Yes").'</option>'."\n";
|
||||||
@ -4194,8 +4195,9 @@ class Form
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$selected=($useempty?'':' selected="selected"');
|
||||||
$resultyesno .= '<option value="'.$yes.'">'.$langs->trans("Yes").'</option>'."\n";
|
$resultyesno .= '<option value="'.$yes.'">'.$langs->trans("Yes").'</option>'."\n";
|
||||||
$resultyesno .= '<option value="'.$no.'" selected="selected">'.$langs->trans("No").'</option>'."\n";
|
$resultyesno .= '<option value="'.$no.'"'.$selected.'>'.$langs->trans("No").'</option>'."\n";
|
||||||
}
|
}
|
||||||
$resultyesno .= '</select>'."\n";
|
$resultyesno .= '</select>'."\n";
|
||||||
return $resultyesno;
|
return $resultyesno;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user