LSform / dataEntryForm: Add forceGeneration parameter

This commit is contained in:
Benjamin Renard 2023-02-10 11:59:55 +01:00
parent f8c38dd3b6
commit 29bfca1792
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC
2 changed files with 42 additions and 18 deletions

View file

@ -155,21 +155,26 @@ et dont la valeur associée est sa configuration.
'label' => '[label du masque de saisie]',
'disabledLayout' => [booleen],
'displayedElements' => array (
'arg1',
'arg2',
'attr1',
'attr2',
...
),
'defaultValues' => array (
'arg3' => [value],
'arg4' => [value],
'attr3' => [value],
'attr4' => [value],
...
),
'requiredAllAttributes' => [booleen],
'requiredAttributes' => array (
'arg1',
'arg2',
'attr1',
'attr2',
...
)
),
'forceGeneration' => array (
'attr1',
'attr2',
...
),
),
...
);]]>
@ -234,6 +239,14 @@ et dont la valeur associée est sa configuration.
</listitem>
</varlistentry>
<varlistentry>
<term>forceGeneration</term>
<listitem>
<simpara>Tableau contenant la liste des attributs dont la génération sera forcée lors de la
validation du formation.</simpara>
</listitem>
</varlistentry>
</variablelist>
</para>
</sect3>

View file

@ -492,6 +492,14 @@ class LSldapObject extends LSlog_staticLoggerClass {
else {
$LSform=false;
}
$forceGeneration = (
$LSform && $LSform -> dataEntryForm?
LSconfig::get(
'forceGeneration', array(), 'array', $LSform -> dataEntryFormConfig
):array()
);
foreach($this -> attrs as $attr_name => $attr) {
$attr_values = $attr -> getValue();
if (!$attr -> isValidate()) {
@ -500,7 +508,10 @@ class LSldapObject extends LSlog_staticLoggerClass {
$retval = false;
}
}
else if( (empty($attr_values)) && ($attr -> isRequired()) ) {
else if(
in_array($attr_name, $forceGeneration)
|| (empty($attr_values) && $attr -> isRequired())
) {
if ( $attr -> canBeGenerated()) {
if ($attr -> generateValue()) {
if (!$this -> validateAttrData($LSform, $attr, $justCheck)) {