diff --git a/src/includes/class/class.LSform.php b/src/includes/class/class.LSform.php index 6807020b..7c761442 100644 --- a/src/includes/class/class.LSform.php +++ b/src/includes/class/class.LSform.php @@ -667,16 +667,17 @@ class LSform extends LSlog_staticLoggerClass { } /** - * Retourne le code HTML d'un champ vide. + * Return the HTML code of an empty form field * - * @param[in] string Le nom du champ du formulaire + * @param[in] $element string The form element name + * @param[in] $value_idx integer|null The value index (optional, default: null == 0) * - * @retval string Le code HTML du champ vide. + * @retval string|null The HTML code of the specified field if exist, null otherwise */ - public function getEmptyField($element) { + public function getEmptyField($element, $value_idx=null) { $element = $this -> getElement($element); if ($element) { - return $element -> getEmptyField(); + return $element -> getEmptyField($value_idx); } else { return; @@ -777,10 +778,12 @@ class LSform extends LSlog_staticLoggerClass { $object = new $_REQUEST['objecttype'](); $object -> loadData($_REQUEST['objectdn']); $form = $object -> getForm($_REQUEST['idform']); - $emptyField=$form -> getEmptyField($_REQUEST['attribute']); + $value_idx = (isset($_REQUEST['value_idx'])?$_REQUEST['value_idx']:0); + $emptyField = $form -> getEmptyField($_REQUEST['attribute'], $value_idx); if ( $emptyField ) { $data = array( - 'html' => $form -> getEmptyField($_REQUEST['attribute']), + 'html' => $emptyField, + 'value_idx' => $value_idx, 'fieldId' => $_REQUEST['fieldId'], 'fieldtype' => get_class($form -> getElement($_REQUEST['attribute'])) ); diff --git a/src/includes/class/class.LSformElement.php b/src/includes/class/class.LSformElement.php index 321e16e2..1c8c6721 100644 --- a/src/includes/class/class.LSformElement.php +++ b/src/includes/class/class.LSformElement.php @@ -322,12 +322,20 @@ class LSformElement extends LSlog_staticLoggerClass { } /** - * Retourne le code HTML d'un champ vide + * Return HTML code of an empty form field * - * @retval string Code HTML d'un champ vide. + * @param[in] $value_idx integer|null The value index (optional, default: null == 0) + * + * @retval string The HTML code of an empty field */ - public function getEmptyField() { - return $this -> fetchTemplate($this -> fieldTemplate); + public function getEmptyField($value_idx=null) { + return $this -> fetchTemplate( + $this -> fieldTemplate, + array( + 'value' => null, + 'value_idx' => intval($value_idx), + ) + ); } /** diff --git a/src/includes/class/class.LSformElement_labeledValue.php b/src/includes/class/class.LSformElement_labeledValue.php index f329edb9..c0b8ed16 100644 --- a/src/includes/class/class.LSformElement_labeledValue.php +++ b/src/includes/class/class.LSformElement_labeledValue.php @@ -59,15 +59,22 @@ class LSformElement_labeledValue extends LSformElement { return $return; } - /** - * Retourne le code HTML d'un champ vide - * - * @retval string Code HTML d'un champ vide. - */ - public function getEmptyField() { - return $this -> fetchTemplate($this -> fieldTemplate,array( - 'labels' => $this -> getParam('html_options.labels'), - )); + /** + * Return HTML code of an empty form field + * + * @param[in] $value_idx integer|null The value index (optional, default: null == 0) + * + * @retval string The HTML code of an empty field + */ + public function getEmptyField($value_idx=null) { + return $this -> fetchTemplate( + $this -> fieldTemplate, + array( + 'value' => null, + 'value_idx' => intval($value_idx), + 'labels' => $this -> getParam('html_options.labels'), + ) + ); } /** diff --git a/src/includes/class/class.LSformElement_mailQuota.php b/src/includes/class/class.LSformElement_mailQuota.php index 3b694955..f3868579 100644 --- a/src/includes/class/class.LSformElement_mailQuota.php +++ b/src/includes/class/class.LSformElement_mailQuota.php @@ -94,16 +94,20 @@ class LSformElement_mailQuota extends LSformElement { return $return; } - /** - * Retourne le code HTML d'un champ vide - * - * @retval string Code HTML d'un champ vide. - */ - public function getEmptyField() { + /** + * Return HTML code of an empty form field + * + * @param[in] $value_idx integer|null The value index (optional, default: null == 0) + * + * @retval string The HTML code of an empty field + */ + public function getEmptyField($value_idx=null) { return $this -> fetchTemplate( $this -> fieldTemplate, array( - 'sizeFacts' => $this -> sizeFacts + 'value' => null, + 'value_idx' => intval($value_idx), + 'sizeFacts' => $this -> sizeFacts, ) ); } diff --git a/src/includes/class/class.LSformElement_quota.php b/src/includes/class/class.LSformElement_quota.php index 13207dc6..e4c68ccc 100644 --- a/src/includes/class/class.LSformElement_quota.php +++ b/src/includes/class/class.LSformElement_quota.php @@ -94,16 +94,20 @@ class LSformElement_quota extends LSformElement { return $return; } - /** - * Retourne le code HTML d'un champ vide - * - * @retval string Code HTML d'un champ vide. - */ - public function getEmptyField() { + /** + * Return HTML code of an empty form field + * + * @param[in] $value_idx integer|null The value index (optional, default: null == 0) + * + * @retval string The HTML code of an empty field + */ + public function getEmptyField($value_idx=null) { return $this -> fetchTemplate( $this -> fieldTemplate, array( - 'sizeFacts' => $this -> sizeFacts + 'value' => null, + 'value_idx' => intval($value_idx), + 'sizeFacts' => $this -> sizeFacts, ) ); } diff --git a/src/includes/class/class.LSformElement_supannCompositeAttribute.php b/src/includes/class/class.LSformElement_supannCompositeAttribute.php index bd72d800..18e5ddfe 100644 --- a/src/includes/class/class.LSformElement_supannCompositeAttribute.php +++ b/src/includes/class/class.LSformElement_supannCompositeAttribute.php @@ -118,13 +118,22 @@ class LSformElement_supannCompositeAttribute extends LSformElement { } - /** - * Retourne le code HTML d'un champ vide - * - * @retval string Code HTML d'un champ vide. - */ - public function getEmptyField() { - return $this -> fetchTemplate($this -> fieldTemplate,array('components' => $this -> components)); + /** + * Return HTML code of an empty form field + * + * @param[in] $value_idx integer|null The value index (optional, default: null == 0) + * + * @retval string The HTML code of an empty field + */ + public function getEmptyField($value_idx=null) { + return $this -> fetchTemplate( + $this -> fieldTemplate, + array( + 'value' => null, + 'value_idx' => intval($value_idx), + 'components' => $this -> components, + ) + ); } /** diff --git a/src/includes/class/class.LSformElement_valueWithUnit.php b/src/includes/class/class.LSformElement_valueWithUnit.php index f96f3ba2..d8fd0d72 100644 --- a/src/includes/class/class.LSformElement_valueWithUnit.php +++ b/src/includes/class/class.LSformElement_valueWithUnit.php @@ -123,16 +123,20 @@ class LSformElement_valueWithUnit extends LSformElement { return $return; } - /** - * Retourne le code HTML d'un champ vide - * - * @retval string Code HTML d'un champ vide. - */ - public function getEmptyField() { + /** + * Return HTML code of an empty form field + * + * @param[in] $value_idx integer|null The value index (optional, default: null == 0) + * + * @retval string The HTML code of an empty field + */ + public function getEmptyField($value_idx=null) { return $this -> fetchTemplate( $this -> fieldTemplate, array( - 'units' => $this -> getUnits() + 'value' => null, + 'value_idx' => intval($value_idx), + 'units' => $this -> getUnits(), ) ); } diff --git a/src/includes/js/LSformElement.js b/src/includes/js/LSformElement.js index 68de834b..60c563fc 100644 --- a/src/includes/js/LSformElement.js +++ b/src/includes/js/LSformElement.js @@ -27,7 +27,8 @@ var LSformElement = new Class({ objecttype: this.LSform.objecttype, objectdn: this.LSform.objectdn, idform: this.LSform.idform, - fieldId: field.id + fieldId: field.id, + value_idx: this.ul.getChildren('li').length, }; LSdebug(data); data.imgload = varLSdefault.loadingImgDisplay(field.li,'inside'); diff --git a/src/templates/default/LSformElement.tpl b/src/templates/default/LSformElement.tpl index 3b762471..0c174dee 100644 --- a/src/templates/default/LSformElement.tpl +++ b/src/templates/default/LSformElement.tpl @@ -1,8 +1,9 @@ -