forked from Wavyzz/dolibarr
Try new function to set array_options to object (extrafields values) with date sent by forms
This commit is contained in:
@@ -341,22 +341,8 @@ else if ($action == 'add' && $user->rights->propal->creer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get extra fields
|
// Fill array 'array_options' with data from add form
|
||||||
foreach ($extralabels as $key => $value)
|
$ret = setOptionalsFromPost($extralabels,$object);*
|
||||||
{
|
|
||||||
$key_type = $extrafields->attribute_type[$key];
|
|
||||||
|
|
||||||
if (in_array($key_type,array('date','datetime')))
|
|
||||||
{
|
|
||||||
// Clean parameters
|
|
||||||
$value_key=dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$value_key=GETPOST("options_".$key);
|
|
||||||
}
|
|
||||||
$object->array_options["options_".$key]=$value_key;
|
|
||||||
}
|
|
||||||
|
|
||||||
$id = $object->create($user);
|
$id = $object->create($user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -752,5 +752,42 @@ class ExtraFields
|
|||||||
$out = '<tr class="liste_titre"><td colspan="4"><strong>'.$this->attribute_label[$key].'</strong></td></tr>';
|
$out = '<tr class="liste_titre"><td colspan="4"><strong>'.$this->attribute_label[$key].'</strong></td></tr>';
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill array_options array for object by extrafields value (using for data send by forms)
|
||||||
|
*
|
||||||
|
* @param array $extralabels $array of extrafields
|
||||||
|
* @param object $object object
|
||||||
|
* @return int 1 if array_options set / 0 if no value
|
||||||
|
*/
|
||||||
|
function setOptionalsFromPost($extralabels,&$object)
|
||||||
|
{
|
||||||
|
global $_POST;
|
||||||
|
|
||||||
|
if (is_array($extralabels))
|
||||||
|
{
|
||||||
|
// Get extra fields
|
||||||
|
foreach ($extralabels as $key => $value)
|
||||||
|
{
|
||||||
|
$key_type = $this->attribute_type[$key];
|
||||||
|
|
||||||
|
if (in_array($key_type,array('date','datetime')))
|
||||||
|
{
|
||||||
|
// Clean parameters
|
||||||
|
$value_key=dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$value_key=GETPOST("options_".$key);
|
||||||
|
}
|
||||||
|
$object->array_options["options_".$key]=$value_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user