Index: src/include/lib/Garradin/Template.php
==================================================================
--- src/include/lib/Garradin/Template.php
+++ src/include/lib/Garradin/Template.php
@@ -167,11 +167,11 @@
$current_value = $_POST[$name];
}
$required_label = array_key_exists('required', $params) ? ' (obligatoire)' : '';
- $out .= sprintf('
%s', $name, $this->escape($label), $required_label);
+ $out = sprintf('%s', $name, $this->escape($label), $required_label);
if (isset($help)) {
$out .= sprintf('%s', $this->escape($help));
}
@@ -179,10 +179,16 @@
$attributes['id'] = 'f_' . $name;
if (array_key_exists('required', $params)) {
$attributes['required'] = 'required';
}
+
+ array_walk($attributes, function ($v, $k) {
+ return sprintf('%s="%s"', $k, $v);
+ });
+
+ $attributes = implode(' ', $attributes);
$out .= '';
if ($type == 'select') {
$out .= sprintf('';
}
elseif ($type == 'textarea') {
- $out .= sprintf('', $attributes, $this->escape($value));
+ $out .= sprintf('', $attributes, $this->escape($current_value));
}
else {
- $out .= sprintf('', $type, $attributes, $this->escape($value));
+ $out .= sprintf('', $type, $attributes, $this->escape($current_value));
}
$out .= '';
return $out;