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]', 'label' => '[label du masque de saisie]',
'disabledLayout' => [booleen], 'disabledLayout' => [booleen],
'displayedElements' => array ( 'displayedElements' => array (
'arg1', 'attr1',
'arg2', 'attr2',
... ...
), ),
'defaultValues' => array ( 'defaultValues' => array (
'arg3' => [value], 'attr3' => [value],
'arg4' => [value], 'attr4' => [value],
... ...
), ),
'requiredAllAttributes' => [booleen], 'requiredAllAttributes' => [booleen],
'requiredAttributes' => array ( 'requiredAttributes' => array (
'arg1', 'attr1',
'arg2', 'attr2',
... ...
) ),
'forceGeneration' => array (
'attr1',
'attr2',
...
),
), ),
... ...
);]]> );]]>
@ -234,6 +239,14 @@ et dont la valeur associée est sa configuration.
</listitem> </listitem>
</varlistentry> </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> </variablelist>
</para> </para>
</sect3> </sect3>

View file

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