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

feat(attributes) Set HTML5 required attribute for required inputs

issue #5910
parent 30ca2761
......@@ -169,7 +169,7 @@ class FileDownloadAttribute extends FileAttribute
$display = '';
if ($this->upload) {
$display .= $this->renderInputField('file', $id);
$display .= $this->renderInputField('submit', 'upload'.$id, array('value' => _('Upload')));
$display .= $this->renderInputField('submit', 'upload'.$id, array('value' => _('Upload'), 'formnovalidate' => 'formnovalidate'));
}
$display .= $this->renderInputField(
'image', 'download'.$id,
......
......@@ -108,6 +108,9 @@ class IntAttribute extends Attribute
$js = $this->managedAttributesJS();
$attributes['onChange'] = 'javascript:'.htmlentities($js, ENT_COMPAT, 'UTF-8');
}
if ($this->isRequired()) {
$attributes['required'] = 'required';
}
$display = $this->renderInputField('number', $id, $attributes);
return $this->renderAcl($display);
}
......
......@@ -43,7 +43,7 @@ class SetAttribute extends Attribute
$values
);
$this->attribute = $attribute;
$this->attribute->setRequired(TRUE);
$this->attribute->setRequired(FALSE);
$this->valueUnicity = $valueUnicity;
}
......@@ -278,8 +278,8 @@ class SetAttribute extends Attribute
function renderButtons ()
{
$id = $this->getHtmlId();
$buttons = $this->renderInputField('submit', 'add'.$id, array('value' => '{msgPool type=addButton}'));
$buttons .= $this->renderInputField('submit', 'del'.$id, array('value' => '{msgPool type=delButton}'));
$buttons = $this->renderInputField('submit', 'add'.$id, array('value' => '{msgPool type=addButton}', 'formnovalidate' => 'formnovalidate'));
$buttons .= $this->renderInputField('submit', 'del'.$id, array('value' => '{msgPool type=delButton}', 'formnovalidate' => 'formnovalidate'));
return $buttons;
}
......@@ -656,7 +656,7 @@ class OrderedArrayAttribute extends SetAttribute
function renderButtons ()
{
$id = $this->getHtmlId();
$buttons = $this->renderInputField('submit', 'add'.$id, array('value' => '{msgPool type=addButton}'));
$buttons = $this->renderInputField('submit', 'add'.$id, array('value' => '{msgPool type=addButton}', 'formnovalidate' => 'formnovalidate'));
return $buttons;
}
}
......
......@@ -80,6 +80,9 @@ class StringAttribute extends Attribute
if ($this->html5pattern !== NULL) {
$attributes['pattern'] = htmlentities($this->html5pattern, ENT_COMPAT, 'UTF-8');
}
if ($this->isRequired()) {
$attributes['required'] = 'required';
}
$display = $this->renderInputField($this->inputType, $id, $attributes);
return $this->renderAcl($display);
}
......@@ -153,7 +156,9 @@ class TextAreaAttribute extends StringAttribute
{
$id = $this->getHtmlId();
$display = '<textarea name="'.$id.'" id="'.$id.'"'.
($this->disabled ? ' disabled="disabled"' : '').'>'.
($this->disabled ? ' disabled="disabled"' : '').
($this->isRequired() ? ' required="required"' : '').
'>'.
'{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}</textarea>';
return $this->renderAcl($display);
}
......
......@@ -249,20 +249,27 @@ class DialogAttribute extends SetAttribute
);
$buttons .= $this->renderInputField(
'submit', 'add'.$id,
array('value' => '{msgPool type=addButton}')
array(
'value' => '{msgPool type=addButton}',
'formnovalidate' => 'formnovalidate'
)
);
$dialogButtonValue = _('Add (dialog)');
}
$buttons .= $this->renderInputField(
'submit', 'add'.$id.'_dialog',
array(
'class' => 'dialog',
'value' => $dialogButtonValue
'class' => 'dialog',
'value' => $dialogButtonValue,
'formnovalidate' => 'formnovalidate'
)
);
$buttons .= $this->renderInputField(
'submit', 'del'.$id,
array('value' => '{msgPool type=delButton}')
array(
'value' => '{msgPool type=delButton}',
'formnovalidate' => 'formnovalidate'
)
);
return $buttons;
}
......@@ -337,8 +344,9 @@ class DialogOrderedArrayAttribute extends OrderedArrayAttribute
return $this->renderInputField(
'submit', 'add'.$id.'_dialog',
array(
'class' => 'dialog',
'value' => '{msgPool type=addButton}'
'class' => 'dialog',
'value' => '{msgPool type=addButton}',
'formnovalidate' => 'formnovalidate'
)
);
}
......
......@@ -51,7 +51,7 @@
<hr/>
<div style='width:99%; text-align:right; padding:5px;'>
<input type='submit' name='dialog_confirm' value='{t}Apply{/t}'/>
<input type='submit' name='dialog_cancel' value='{t}Cancel{/t}'/>
<input type='submit' formnovalidate="formnovalidate" name='dialog_cancel' value='{t}Cancel{/t}'/>
</div>
</div>
</div>
......@@ -22,7 +22,7 @@
<hr/>
<div style='width:100%; text-align:right; padding:5px;'>
<input type='submit' name='dialog_cancel' value='{t}Close{/t}'>
<input type='submit' formnovalidate="formnovalidate" name='dialog_cancel' value='{t}Close{/t}'>
</div>
</div>
</div>
Markdown is supported
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