diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 6f2ec2acfb6..1778b46995e 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -44,6 +44,41 @@ class FormSetup /** @var int */ protected $maxItemRank; + /** + * this is an html string display before output form + * @var string + */ + public $htmlBeforeOutputForm = ''; + + /** + * this is an html string display after output form + * @var string + */ + public $htmlAfterOutputForm = ''; + + /** + * this is an html string display on buttons zone + * @var string + */ + public $htmlOutputMoreButton = ''; + + + /** + * + * @var array + */ + public $formAttributes = array( + 'action' => '', // set in __construct + 'method' => 'POST' + ); + + /** + * an list of hidden inputs used only in edit mode + * @var array + */ + public $formHiddenInputs = array(); + + /** * Constructor * @@ -55,6 +90,11 @@ class FormSetup global $langs; $this->db = $db; $this->form = new Form($this->db); + $this->formAttributes['action'] = $_SERVER["PHP_SELF"]; + + $this->formHiddenInputs['token'] = newToken(); + $this->formHiddenInputs['action'] = 'update'; + if ($outputLangs) { $this->langs = $outputLangs; @@ -63,6 +103,27 @@ class FormSetup } } + /** + * Generate an attributes string form an input array + * @param array $attributes an array of attributes keys and values, + * @return string + */ + static public function generateAttributesStringFromArray($attributes) + { + $Aattr = array(); + if (is_array($attributes)) { + foreach ($attributes as $attribute => $value) { + if (is_array($value) || is_object($value)) { + continue; + } + $Aattr[] = $attribute.'="'.dol_escape_htmltag($value).'"'; + } + } + + return !empty($Aattr)?implode(' ', $Aattr):''; + } + + /** * @param bool $editMode true will display output on edit mod * @return string @@ -83,12 +144,70 @@ class FormSetup if ($reshook > 0) { return $hookmanager->resPrint; } else { - $out = ''; + $out = ''; + $out.= $this->htmlBeforeOutputForm; + if ($editMode) { - $out .= ''; + $out.= '