Commit ef5ce6bc authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(attributes) Remove form validation attributes from template edition

This removes required, pattern and special input types from template
 edition rendering so that masks can be used.

issue #5910
Showing with 36 additions and 19 deletions
+36 -19
...@@ -120,12 +120,13 @@ class IntAttribute extends Attribute ...@@ -120,12 +120,13 @@ class IntAttribute extends Attribute
function renderTemplateInput () function renderTemplateInput ()
{ {
$id = $this->getHtmlId(); $id = $this->getHtmlId();
$display = $this->renderInputField( $attributes = array(
'text', $id, 'value' => '{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}'
array(
'value' => '{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}'
)
); );
if ($this->isSubAttribute) {
$attributes['class'] = 'subattribute';
}
$display = $this->renderInputField('text', $id, $attributes);
return $this->renderAcl($display); return $this->renderAcl($display);
} }
} }
......
...@@ -91,6 +91,22 @@ class StringAttribute extends Attribute ...@@ -91,6 +91,22 @@ class StringAttribute extends Attribute
return $this->renderAcl($display); return $this->renderAcl($display);
} }
function renderTemplateInput ()
{
$id = $this->getHtmlId();
$attributes = array(
'value' => '{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}'
);
if ($this->autocomplete !== NULL) {
$attributes['autocomplete'] = ($this->autocomplete ? 'on' : 'off' );
}
if ($this->isSubAttribute) {
$attributes['class'] = 'subattribute';
}
$display = $this->renderInputField('text', $id, $attributes);
return $this->renderAcl($display);
}
function fixPostValue ($value) function fixPostValue ($value)
{ {
/* Replace CRLF by LF, to avoid non-ASCII chars in multiline values (mainly useful for textarea) */ /* Replace CRLF by LF, to avoid non-ASCII chars in multiline values (mainly useful for textarea) */
...@@ -166,6 +182,17 @@ class TextAreaAttribute extends StringAttribute ...@@ -166,6 +182,17 @@ class TextAreaAttribute extends StringAttribute
'{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}</textarea>'; '{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}</textarea>';
return $this->renderAcl($display); return $this->renderAcl($display);
} }
function renderTemplateInput ()
{
$id = $this->getHtmlId();
$display = '<textarea name="'.$id.'" id="'.$id.'"'.
($this->disabled ? ' disabled="disabled"' : '').
($this->isSubAttribute ? ' class="subattribute"' : '').
'>'.
'{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}</textarea>';
return $this->renderAcl($display);
}
} }
/*! \brief This class allow to handle easily a String LDAP attribute that contains a password /*! \brief This class allow to handle easily a String LDAP attribute that contains a password
...@@ -174,25 +201,14 @@ class TextAreaAttribute extends StringAttribute ...@@ -174,25 +201,14 @@ class TextAreaAttribute extends StringAttribute
class PasswordAttribute extends StringAttribute class PasswordAttribute extends StringAttribute
{ {
protected $autocomplete = FALSE; protected $autocomplete = FALSE;
protected $inputType = 'password';
function renderFormInput () function renderFormInput ()
{ {
$id = $this->getHtmlId(); $display = parent::renderFormInput();
$display = $this->renderInputField(
'password', $id,
array(
'value' => '{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}',
'autocomplete' => ($this->autocomplete ? 'on' : 'off'),
)
);
if ($this->autocomplete === FALSE) { if ($this->autocomplete === FALSE) {
$display = '{literal}<input autocomplete="off" value="foolautocompleteworkaround" type="text" style="display:none;"/>{/literal}'.$display; $display = '{literal}<input autocomplete="off" value="foolautocompleteworkaround" type="text" style="display:none;"/>{/literal}'.$display;
} }
return $this->renderAcl($display); return $display;
}
function renderTemplateInput ()
{
return parent::renderFormInput();
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment