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( diff --git a/lib/noticeform.php b/lib/noticeform.php index f4a3ecfd86..e6385e495e 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -208,6 +208,7 @@ class NoticeForm extends Form sprintf(_('What\'s up, %s?'), $this->user->nickname)); // XXX: vary by defined max size $this->out->element('textarea', array('class' => 'notice_data-text', + 'required' => 'required', 'cols' => 35, 'rows' => 4, 'name' => 'status_textarea'), diff --git a/plugins/Bookmark/forms/bookmark.php b/plugins/Bookmark/forms/bookmark.php index 20101e1eff..f577a32477 100644 --- a/plugins/Bookmark/forms/bookmark.php +++ b/plugins/Bookmark/forms/bookmark.php @@ -121,7 +121,8 @@ class BookmarkForm extends Form _m('LABEL','URL'), $this->_url, null, - 'url'); + 'url', + true); // HTML5 "required" attribute $this->unli(); if (!empty($this->_thumbnail)) { @@ -142,7 +143,8 @@ class BookmarkForm extends Form _m('LABEL','Title'), $this->_title, null, - 'title'); + 'title', + true); // HTML5 "required" attribute $this->unli(); $this->li(); diff --git a/plugins/Bookmark/forms/initialbookmark.php b/plugins/Bookmark/forms/initialbookmark.php index a82941b16a..e41d6b9618 100644 --- a/plugins/Bookmark/forms/initialbookmark.php +++ b/plugins/Bookmark/forms/initialbookmark.php @@ -78,7 +78,8 @@ class InitialBookmarkForm extends Form _m('LABEL','URL'), null, null, - 'url'); + 'url', + true); // HTML5 "required" attribute $this->unli(); $this->out->elementEnd('ul'); diff --git a/plugins/Event/forms/event.php b/plugins/Event/forms/event.php index 8100e5903b..a19fd80418 100644 --- a/plugins/Event/forms/event.php +++ b/plugins/Event/forms/event.php @@ -104,7 +104,8 @@ class EventForm extends Form null, // TRANS: Field title on event form. _m('Title of the event.'), - 'title'); + 'title', + true); // HTML5 "required" attribute $this->unli(); $this->li(); @@ -195,7 +196,8 @@ class EventForm extends Form null, // TRANS: Field title on event form. _m('Description of the event.'), - 'description'); + 'description', + true); // HTML5 "required" attribute $this->unli(); $this->out->elementEnd('ul'); diff --git a/plugins/Poll/forms/newpoll.php b/plugins/Poll/forms/newpoll.php index 309125a686..5c527c5cd2 100644 --- a/plugins/Poll/forms/newpoll.php +++ b/plugins/Poll/forms/newpoll.php @@ -107,7 +107,9 @@ class NewpollForm extends Form _m('Question'), $this->question, // TRANS: Field title on the page to create a poll. - _m('What question are people answering?')); + _m('What question are people answering?'), + 'question', + true); // HTML5 "required" attribute $this->unli(); $max = 5; @@ -128,7 +130,8 @@ class NewpollForm extends Form sprintf(_m('Option %d'), $i + 1), $default, null, - 'option' . ($i + 1)); + 'option' . ($i + 1), + $i<2); // HTML5 "required" attribute for 2 options $this->unli(); } diff --git a/plugins/QnA/forms/qnanewanswer.php b/plugins/QnA/forms/qnanewanswer.php index c0ae220ff1..3c67d89020 100644 --- a/plugins/QnA/forms/qnanewanswer.php +++ b/plugins/QnA/forms/qnanewanswer.php @@ -111,7 +111,7 @@ class QnanewanswerForm extends Form $out->hidden('qna-question-id', $id, 'id'); // TRANS: Field label. - $out->textarea('qna-answer', _m('Enter your answer'), null, null, 'answer'); + $out->textarea('qna-answer', _m('Enter your answer'), null, null, 'answer', true); } /** diff --git a/plugins/QnA/forms/qnanewquestion.php b/plugins/QnA/forms/qnanewquestion.php index a1a2a94483..eca0187982 100644 --- a/plugins/QnA/forms/qnanewquestion.php +++ b/plugins/QnA/forms/qnanewquestion.php @@ -111,7 +111,8 @@ class QnanewquestionForm extends Form $this->title, // TRANS: Field title for a new question. _m('The title of your question.'), - 'title' + 'title', + true // HTML5 "required" attribute ); $this->unli(); $this->li(); @@ -122,7 +123,8 @@ class QnanewquestionForm extends Form $this->description, // TRANS: Field title for question details. _m('Your question in detail.'), - 'description' + 'description', + true // HTML5 "required" attribute ); $this->unli();