public static $typeMappings = array(
'api' => 'HTMLApiField',
'text' => 'HTMLTextField',
+ 'textwithbutton' => 'HTMLTextFieldWithButton',
'textarea' => 'HTMLTextAreaField',
'select' => 'HTMLSelectField',
'radio' => 'HTMLRadioField',
'selectorother' => 'HTMLSelectOrOtherField',
'selectandother' => 'HTMLSelectAndOtherField',
'namespaceselect' => 'HTMLSelectNamespace',
+ 'namespaceselectwithbutton' => 'HTMLSelectNamespaceWithButton',
'tagfilter' => 'HTMLTagFilter',
'submit' => 'HTMLSubmitField',
'hidden' => 'HTMLHiddenField',
'email' => 'HTMLTextField',
'password' => 'HTMLTextField',
'url' => 'HTMLTextField',
+ 'title' => 'HTMLTitleTextField',
);
public $mFieldData;
protected $mFieldTree;
protected $mShowReset = false;
protected $mShowSubmit = true;
- protected $mSubmitModifierClass = 'mw-ui-constructive';
+ protected $mSubmitFlag = 'constructive';
protected $mSubmitCallback;
protected $mValidationErrorMessage;
$html = ''
. $this->getErrors( $submitResult )
- . $this->mHeader
+ // In OOUI forms, we handle mHeader elsewhere. FIXME This is horrible.
+ . ( $this->getDisplayFormat() === 'ooui' ? '' : $this->mHeader )
. $this->getBody()
. $this->getHiddenFields()
. $this->getButtons()
$attribs = array(
'action' => $this->getAction(),
'method' => $this->getMethod(),
- 'class' => array( 'visualClear' ),
'enctype' => $encType,
);
if ( !empty( $this->mId ) ) {
function wrapForm( $html ) {
# Include a <fieldset> wrapper for style, if requested.
if ( $this->mWrapperLegend !== false ) {
- $html = Xml::fieldset( $this->mWrapperLegend, $html );
+ $legend = is_string( $this->mWrapperLegend ) ? $this->mWrapperLegend : false;
+ $html = Xml::fieldset( $legend, $html );
}
- return Html::rawElement( 'form', $this->getFormAttributes(), $html );
+ return Html::rawElement( 'form', $this->getFormAttributes() + array( 'class' => 'visualClear' ), $html );
}
/**
$attribs['class'] = array( 'mw-htmlform-submit' );
if ( $useMediaWikiUIEverywhere ) {
- array_push( $attribs['class'], 'mw-ui-button', $this->mSubmitModifierClass );
+ array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-' . $this->mSubmitFlag );
}
$buttons .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n";
* @since 1.24
*/
public function setSubmitDestructive() {
- $this->mSubmitModifierClass = 'mw-ui-destructive';
+ $this->mSubmitFlag = 'destructive';
}
/**
* @since 1.25
*/
public function setSubmitProgressive() {
- $this->mSubmitModifierClass = 'mw-ui-progressive';
+ $this->mSubmitFlag = 'progressive';
}
/**
* Prompt the whole form to be wrapped in a "<fieldset>", with
* this text as its "<legend>" element.
*
- * @param string|bool $legend HTML to go inside the "<legend>" element, or
- * false for no <legend>
- * Will be escaped
+ * @param string|bool $legend If false, no wrapper or legend will be displayed.
+ * If true, a wrapper will be displayed, but no legend.
+ * If a string, a wrapper will be displayed with that string as a legend.
+ * The string will be escaped before being output (this doesn't support HTML).
*
* @return HTMLForm $this for chaining calls (since 1.20)
*/
if ( $sectionName ) {
$config['id'] = Sanitizer::escapeId( $sectionName );
}
+ if ( is_string( $this->mWrapperLegend ) ) {
+ $config['label'] = $this->mWrapperLegend;
+ }
$fieldset = new OOUI\FieldsetLayout( $config );
// Ewww. We should pass this as $config['items'], but there might be string snippets.
$fieldset->group->appendContent( new OOUI\HtmlSnippet( $html ) );
- $html = $fieldset->toString();
+ $html = $fieldset;
} else {
$html = Html::rawElement( 'div', $attribs, "\n$html\n" );
}
}
- if ( $this->mSubSectionBeforeFields ) {
- return $subsectionHtml . "\n" . $html;
+ if ( $subsectionHtml ) {
+ if ( $this->mSubSectionBeforeFields ) {
+ return $subsectionHtml . "\n" . $html;
+ } else {
+ return $html . "\n" . $subsectionHtml;
+ }
} else {
- return $html . "\n" . $subsectionHtml;
+ return $html;
}
}