Les templates
text textarea mail password select date file disposent d'un nouvel attribut 'required' => true qui insère une étoile rouge à droite du label et qui ajoute l'attribut required au champ ce qui permet d'afficher le message par le navigateur.
This commit is contained in:
parent
5a5682a0f6
commit
462fc16ea0
@ -245,6 +245,7 @@ class template
|
|||||||
'readonly' => false,
|
'readonly' => false,
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'type' => 'date',
|
'type' => 'date',
|
||||||
|
'required' => false,
|
||||||
], $attributes);
|
], $attributes);
|
||||||
// Traduction de l'aide et de l'étiquette
|
// Traduction de l'aide et de l'étiquette
|
||||||
$attributes['label'] = helper::translate($attributes['label']);
|
$attributes['label'] = helper::translate($attributes['label']);
|
||||||
@ -271,12 +272,21 @@ class template
|
|||||||
} else {
|
} else {
|
||||||
$attributes['value'] = ($attributes['value'] ? helper::filter($attributes['value'], $filter) : '');
|
$attributes['value'] = ($attributes['value'] ? helper::filter($attributes['value'], $filter) : '');
|
||||||
}
|
}
|
||||||
|
// Gestion du champ obligatoire
|
||||||
|
if (isset($attributes['required']) && $attributes['required']) {
|
||||||
|
// Affiche l'astérisque dans le label
|
||||||
|
$required = ' required-field';
|
||||||
|
// Ajoute l'attribut required au champ input
|
||||||
|
$attributes['required'] = 'required';
|
||||||
|
}
|
||||||
// Début du wrapper
|
// Début du wrapper
|
||||||
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
||||||
// Label
|
// Label
|
||||||
if ($attributes['label']) {
|
if ($attributes['label']) {
|
||||||
$html .= self::label($attributes['id'], $attributes['label'], [
|
$html .= self::label($attributes['id'], $attributes['label'], [
|
||||||
'help' => $attributes['help']
|
'help' => $attributes['help'],
|
||||||
|
// Ajoute la classe required-field si le champ est obligatoire
|
||||||
|
'class' => isset($required) ? $required : ''
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Notice
|
// Notice
|
||||||
@ -326,7 +336,8 @@ class template
|
|||||||
'type' => 2,
|
'type' => 2,
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'folder' => '',
|
'folder' => '',
|
||||||
'language' => 'fr_FR'
|
'language' => 'fr_FR',
|
||||||
|
'required' => false,
|
||||||
], $attributes);
|
], $attributes);
|
||||||
// Traduction de l'aide et de l'étiquette
|
// Traduction de l'aide et de l'étiquette
|
||||||
$attributes['value'] = helper::translate($attributes['value']);
|
$attributes['value'] = helper::translate($attributes['value']);
|
||||||
@ -335,6 +346,13 @@ class template
|
|||||||
if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
|
if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
|
||||||
$attributes['value'] = common::$inputBefore[$attributes['id']];
|
$attributes['value'] = common::$inputBefore[$attributes['id']];
|
||||||
}
|
}
|
||||||
|
// Gestion du champ obligatoire
|
||||||
|
if (isset($attributes['required']) && $attributes['required']) {
|
||||||
|
// Affiche l'astérisque dans le label
|
||||||
|
$required = ' required-field';
|
||||||
|
// Ajoute l'attribut required au champ input
|
||||||
|
$attributes['required'] = 'required';
|
||||||
|
}
|
||||||
// Début du wrapper
|
// Début du wrapper
|
||||||
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
||||||
// Notice
|
// Notice
|
||||||
@ -347,7 +365,9 @@ class template
|
|||||||
// Label
|
// Label
|
||||||
if ($attributes['label']) {
|
if ($attributes['label']) {
|
||||||
$html .= self::label($attributes['id'], $attributes['label'], [
|
$html .= self::label($attributes['id'], $attributes['label'], [
|
||||||
'help' => $attributes['help']
|
'help' => $attributes['help'],
|
||||||
|
// Ajoute la classe required-field si le champ est obligatoire
|
||||||
|
'class' => isset($required) ? $required : ''
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Champ caché contenant l'url de la page
|
// Champ caché contenant l'url de la page
|
||||||
@ -362,16 +382,16 @@ class template
|
|||||||
$html .= sprintf(
|
$html .= sprintf(
|
||||||
'<a
|
'<a
|
||||||
href="' .
|
href="' .
|
||||||
helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php' .
|
helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php' .
|
||||||
'?relative_url=1' .
|
'?relative_url=1' .
|
||||||
'&lang=' . $attributes['language'] .
|
'&lang=' . $attributes['language'] .
|
||||||
'&field_id=' . $attributes['id'] .
|
'&field_id=' . $attributes['id'] .
|
||||||
'&type=' . $attributes['type'] .
|
'&type=' . $attributes['type'] .
|
||||||
'&akey=' . md5_file(core::DATA_DIR . 'core.json') .
|
'&akey=' . md5_file(core::DATA_DIR . 'core.json') .
|
||||||
// Ajoute le nom du dossier si la variable est passée
|
// Ajoute le nom du dossier si la variable est passée
|
||||||
(empty($attributes['folder']) ? '&fldr=/': '&fldr=' . $attributes['folder']) .
|
(empty($attributes['folder']) ? '&fldr=/' : '&fldr=' . $attributes['folder']) .
|
||||||
($attributes['extensions'] ? '&extensions=' . $attributes['extensions'] : '')
|
($attributes['extensions'] ? '&extensions=' . $attributes['extensions'] : '')
|
||||||
. '"
|
. '"
|
||||||
class="inputFile %s %s"
|
class="inputFile %s %s"
|
||||||
%s
|
%s
|
||||||
data-lity
|
data-lity
|
||||||
@ -583,7 +603,8 @@ class template
|
|||||||
'name' => $nameId,
|
'name' => $nameId,
|
||||||
'placeholder' => '',
|
'placeholder' => '',
|
||||||
'readonly' => false,
|
'readonly' => false,
|
||||||
'value' => ''
|
'value' => '',
|
||||||
|
'required' => false,
|
||||||
], $attributes);
|
], $attributes);
|
||||||
// Traduction de l'aide et de l'étiquette
|
// Traduction de l'aide et de l'étiquette
|
||||||
$attributes['label'] = helper::translate($attributes['label']);
|
$attributes['label'] = helper::translate($attributes['label']);
|
||||||
@ -593,12 +614,21 @@ class template
|
|||||||
if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
|
if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
|
||||||
$attributes['value'] = common::$inputBefore[$attributes['id']];
|
$attributes['value'] = common::$inputBefore[$attributes['id']];
|
||||||
}
|
}
|
||||||
|
// Gestion du champ obligatoire
|
||||||
|
if (isset($attributes['required']) && $attributes['required']) {
|
||||||
|
// Affiche l'astérisque dans le label
|
||||||
|
$required = ' required-field';
|
||||||
|
// Ajoute l'attribut required au champ input
|
||||||
|
$attributes['required'] = 'required';
|
||||||
|
}
|
||||||
// Début du wrapper
|
// Début du wrapper
|
||||||
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
||||||
// Label
|
// Label
|
||||||
if ($attributes['label']) {
|
if ($attributes['label']) {
|
||||||
$html .= self::label($attributes['id'], $attributes['label'], [
|
$html .= self::label($attributes['id'], $attributes['label'], [
|
||||||
'help' => $attributes['help']
|
'help' => $attributes['help'],
|
||||||
|
// Ajoute la classe required-field si le champ est obligatoire
|
||||||
|
'class' => isset($required) ? $required : ''
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Notice
|
// Notice
|
||||||
@ -651,18 +681,28 @@ class template
|
|||||||
//'maxlength' => '500',
|
//'maxlength' => '500',
|
||||||
'name' => $nameId,
|
'name' => $nameId,
|
||||||
'placeholder' => '',
|
'placeholder' => '',
|
||||||
'readonly' => false
|
'readonly' => false,
|
||||||
|
'required' => false,
|
||||||
], $attributes);
|
], $attributes);
|
||||||
// Traduction de l'aide et de l'étiquette
|
// Traduction de l'aide et de l'étiquette
|
||||||
$attributes['label'] = helper::translate($attributes['label']);
|
$attributes['label'] = helper::translate($attributes['label']);
|
||||||
//$attributes['placeholder'] = helper::translate($attributes['placeholder']);
|
//$attributes['placeholder'] = helper::translate($attributes['placeholder']);
|
||||||
$attributes['help'] = helper::translate($attributes['help']);
|
$attributes['help'] = helper::translate($attributes['help']);
|
||||||
|
// Gestion du champ obligatoire
|
||||||
|
if (isset($attributes['required']) && $attributes['required']) {
|
||||||
|
// Affiche l'astérisque dans le label
|
||||||
|
$required = ' required-field';
|
||||||
|
// Ajoute l'attribut required au champ input
|
||||||
|
$attributes['required'] = 'required';
|
||||||
|
}
|
||||||
// Début du wrapper
|
// Début du wrapper
|
||||||
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
||||||
// Label
|
// Label
|
||||||
if ($attributes['label']) {
|
if ($attributes['label']) {
|
||||||
$html .= self::label($attributes['id'], $attributes['label'], [
|
$html .= self::label($attributes['id'], $attributes['label'], [
|
||||||
'help' => $attributes['help']
|
'help' => $attributes['help'],
|
||||||
|
// Ajoute la classe required-field si le champ est obligatoire
|
||||||
|
'class' => isset($required) ? $required : ''
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Notice
|
// Notice
|
||||||
@ -705,7 +745,8 @@ class template
|
|||||||
'name' => $nameId,
|
'name' => $nameId,
|
||||||
'selected' => '',
|
'selected' => '',
|
||||||
'font' => [],
|
'font' => [],
|
||||||
'multiple' => ''
|
'multiple' => '',
|
||||||
|
'required' => false,
|
||||||
], $attributes);
|
], $attributes);
|
||||||
// Traduction de l'aide et de l'étiquette
|
// Traduction de l'aide et de l'étiquette
|
||||||
$attributes['label'] = helper::translate($attributes['label']);
|
$attributes['label'] = helper::translate($attributes['label']);
|
||||||
@ -719,12 +760,21 @@ class template
|
|||||||
if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
|
if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
|
||||||
$attributes['selected'] = common::$inputBefore[$attributes['id']];
|
$attributes['selected'] = common::$inputBefore[$attributes['id']];
|
||||||
}
|
}
|
||||||
|
// Gestion du champ obligatoire
|
||||||
|
if (isset($attributes['required']) && $attributes['required']) {
|
||||||
|
// Affiche l'astérisque dans le label
|
||||||
|
$required = ' required-field';
|
||||||
|
// Ajoute l'attribut required au champ input
|
||||||
|
$attributes['required'] = 'required';
|
||||||
|
}
|
||||||
// Début du wrapper
|
// Début du wrapper
|
||||||
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
||||||
// Label
|
// Label
|
||||||
if ($attributes['label']) {
|
if ($attributes['label']) {
|
||||||
$html .= self::label($attributes['id'], $attributes['label'], [
|
$html .= self::label($attributes['id'], $attributes['label'], [
|
||||||
'help' => $attributes['help']
|
'help' => $attributes['help'],
|
||||||
|
// Ajoute la classe required-field si le champ est obligatoire
|
||||||
|
'class' => isset($required) ? $required : ''
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Notice
|
// Notice
|
||||||
@ -896,7 +946,8 @@ class template
|
|||||||
'placeholder' => '',
|
'placeholder' => '',
|
||||||
'readonly' => false,
|
'readonly' => false,
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'type' => 'text'
|
'type' => 'text',
|
||||||
|
'required' => false,
|
||||||
], $attributes);
|
], $attributes);
|
||||||
// Traduction de l'aide et de l'étiquette
|
// Traduction de l'aide et de l'étiquette
|
||||||
$attributes['label'] = helper::translate($attributes['label']);
|
$attributes['label'] = helper::translate($attributes['label']);
|
||||||
@ -906,12 +957,21 @@ class template
|
|||||||
if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
|
if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
|
||||||
$attributes['value'] = common::$inputBefore[$attributes['id']];
|
$attributes['value'] = common::$inputBefore[$attributes['id']];
|
||||||
}
|
}
|
||||||
|
// Gestion du champ obligatoire
|
||||||
|
if (isset($attributes['required']) && $attributes['required']) {
|
||||||
|
// Affiche l'astérisque dans le label
|
||||||
|
$required = ' required-field';
|
||||||
|
// Ajoute l'attribut required au champ input
|
||||||
|
$attributes['required'] = 'required';
|
||||||
|
}
|
||||||
// Début du wrapper
|
// Début du wrapper
|
||||||
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
||||||
// Label
|
// Label
|
||||||
if ($attributes['label']) {
|
if ($attributes['label']) {
|
||||||
$html .= self::label($attributes['id'], $attributes['label'], [
|
$html .= self::label($attributes['id'], $attributes['label'], [
|
||||||
'help' => $attributes['help']
|
'help' => $attributes['help'],
|
||||||
|
// Ajoute la classe required-field si le champ est obligatoire
|
||||||
|
'class' => isset($required) ? $required : ''
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Notice
|
// Notice
|
||||||
@ -953,7 +1013,8 @@ class template
|
|||||||
//'maxlength' => '500',
|
//'maxlength' => '500',
|
||||||
'name' => $nameId,
|
'name' => $nameId,
|
||||||
'readonly' => false,
|
'readonly' => false,
|
||||||
'value' => ''
|
'value' => '',
|
||||||
|
'required' => false,
|
||||||
], $attributes);
|
], $attributes);
|
||||||
// Traduction de l'aide et de l'étiquette
|
// Traduction de l'aide et de l'étiquette
|
||||||
$attributes['label'] = helper::translate($attributes['label']);
|
$attributes['label'] = helper::translate($attributes['label']);
|
||||||
@ -962,12 +1023,21 @@ class template
|
|||||||
if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
|
if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
|
||||||
$attributes['value'] = common::$inputBefore[$attributes['id']];
|
$attributes['value'] = common::$inputBefore[$attributes['id']];
|
||||||
}
|
}
|
||||||
|
// Gestion du champ obligatoire
|
||||||
|
if (isset($attributes['required']) && $attributes['required']) {
|
||||||
|
// Affiche l'astérisque dans le label
|
||||||
|
$required = ' required-field';
|
||||||
|
// Ajoute l'attribut required au champ input
|
||||||
|
$attributes['required'] = 'required';
|
||||||
|
}
|
||||||
// Début du wrapper
|
// Début du wrapper
|
||||||
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
||||||
// Label
|
// Label
|
||||||
if ($attributes['label']) {
|
if ($attributes['label']) {
|
||||||
$html .= self::label($attributes['id'], $attributes['label'], [
|
$html .= self::label($attributes['id'], $attributes['label'], [
|
||||||
'help' => $attributes['help']
|
'help' => $attributes['help'],
|
||||||
|
// Ajoute la classe required-field si le champ est obligatoire
|
||||||
|
'class' => isset($required) ? $required : ''
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Notice
|
// Notice
|
||||||
|
@ -353,6 +353,14 @@ td>.col12 {
|
|||||||
color: #E74C3C;
|
color: #E74C3C;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Asterisque des champs obligatoires */
|
||||||
|
.required-field::after {
|
||||||
|
content: '\00204E';
|
||||||
|
color: #E74C3C;
|
||||||
|
margin-left: 4px;
|
||||||
|
font-size: larger;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Mauvaise position dans les champs File
|
/* Mauvaise position dans les champs File
|
||||||
.inputFile.notice {
|
.inputFile.notice {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user