* @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
* @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',
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);
* @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
*/
$instructions = null,
$name = null,
$cols = null,
- $rows = null
+ $rows = null,
+ $required = false
) {
$this->element('label', array('for' => $id), $label);
$attrs = array(
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'),
_m('LABEL','URL'),
$this->_url,
null,
- 'url');
+ 'url',
+ true); // HTML5 "required" attribute
$this->unli();
if (!empty($this->_thumbnail)) {
_m('LABEL','Title'),
$this->_title,
null,
- 'title');
+ 'title',
+ true); // HTML5 "required" attribute
$this->unli();
$this->li();
_m('LABEL','URL'),
null,
null,
- 'url');
+ 'url',
+ true); // HTML5 "required" attribute
$this->unli();
$this->out->elementEnd('ul');
null,
// TRANS: Field title on event form.
_m('Title of the event.'),
- 'title');
+ 'title',
+ true); // HTML5 "required" attribute
$this->unli();
$this->li();
null,
// TRANS: Field title on event form.
_m('Description of the event.'),
- 'description');
+ 'description',
+ true); // HTML5 "required" attribute
$this->unli();
$this->out->elementEnd('ul');
_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;
sprintf(_m('Option %d'), $i + 1),
$default,
null,
- 'option' . ($i + 1));
+ 'option' . ($i + 1),
+ $i<2); // HTML5 "required" attribute for 2 options
$this->unli();
}
$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);
}
/**
$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();
$this->description,
// TRANS: Field title for question details.
_m('Your question in detail.'),
- 'description'
+ 'description',
+ true // HTML5 "required" attribute
);
$this->unli();