X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fhtmloutputter.php;fp=lib%2Fhtmloutputter.php;h=f1496768b12b0b540cb9f97594aec1d72459bc5f;hb=a2a2105058179e3cb3a69610aee37289bb1f2cc9;hp=369cd5936e6a5aa9a284ec9ff4bc751758733658;hpb=0777aa548754b67d2f63607a0e7a85f954bf516d;p=quix0rs-gnu-social.git diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 369cd5936e..f1496768b1 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -179,6 +179,7 @@ class HTMLOutputter extends XMLOutputter * @param string $instructions instructions for valid input * @param string $name name of the element; if null, the id will * be used + * @param bool $required HTML5 required attribute (exclude when false) * * @todo add a $maxLength parameter * @todo add a $size parameter @@ -186,7 +187,7 @@ class HTMLOutputter extends XMLOutputter * @return void */ - function input($id, $label, $value=null, $instructions=null, $name=null) + function input($id, $label, $value=null, $instructions=null, $name=null, $required=false) { $this->element('label', array('for' => $id), $label); $attrs = array('type' => 'text', @@ -195,6 +196,9 @@ class HTMLOutputter extends XMLOutputter if (!is_null($value)) { // value can be 0 or '' $attrs['value'] = $value; } + if (!empty($required)) { + $attrs['required'] = 'required'; + } $this->element('input', $attrs); if ($instructions) { $this->element('p', 'form_guide', $instructions); @@ -527,6 +531,7 @@ class HTMLOutputter extends XMLOutputter * @param string $name name of textarea; if null, $id will be used * @param int $cols number of columns * @param int $rows number of rows + * @param bool $required HTML5 required attribute (exclude when false) * * @return void */ @@ -538,7 +543,8 @@ class HTMLOutputter extends XMLOutputter $instructions = null, $name = null, $cols = null, - $rows = null + $rows = null, + $required = false ) { $this->element('label', array('for' => $id), $label); $attrs = array(