* through HTMLForm::$typeMappings to get the class name.
* 'default' -- default value when the form is displayed
* 'id' -- HTML id attribute
- * 'cssclass' -- CSS class
+ * 'cssclass' -- CSS class
* 'options' -- varies according to the specific object.
* 'label-message' -- message key for a message to use as the label.
* can be an array of msg key and then parameters to
: $value->getDefault();
$tableHtml .= $value->getTableRow( $v );
- if ( $value->getLabel() != ' ' )
+ if ( $value->getLabel() != ' ' )
$hasLeftColumn = true;
} elseif ( is_array( $value ) ) {
$section = $this->displaySection( $value, $key );
global $wgRequest;
$errors = $this->validate( $value, $this->mParent->mFieldData );
+
+ $cellAttributes = array();
+ $verticalLabel = false;
+
+ if ( !empty($this->mParams['vertical-label']) ) {
+ $cellAttributes['colspan'] = 2;
+ $verticalLabel = true;
+ }
if ( $errors === true || !$wgRequest->wasPosted() ) {
$errors = '';
$errors = Html::rawElement( 'span', array( 'class' => 'error' ), $errors );
}
- $html = $this->getLabelHtml();
- $html .= Html::rawElement(
+ $label = $this->getLabelHtml( $cellAttributes );
+ $field = Html::rawElement(
'td',
- array( 'class' => 'mw-input' ),
+ array( 'class' => 'mw-input' ) + $cellAttributes,
$this->getInputHTML( $value ) . "\n$errors"
);
-
+
$fieldType = get_class( $this );
-
- $html = Html::rawElement(
- 'tr',
- array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass}" ),
- $html
- ) . "\n";
+
+ if ($verticalLabel) {
+ $html = Html::rawElement( 'tr',
+ array( 'class' => 'mw-htmlform-vertical-label' ), $label );
+ $html .= Html::rawElement( 'tr',
+ array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass}" ),
+ $field );
+ } else {
+ $html = Html::rawElement( 'tr',
+ array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass}" ),
+ $label . $field );
+ }
$helptext = null;
function getLabel() {
return $this->mLabel;
}
- function getLabelHtml() {
+ function getLabelHtml( $cellAttributes = array() ) {
# Don't output a for= attribute for labels with no associated input.
# Kind of hacky here, possibly we don't want these to be <label>s at all.
$for = array();
$for['for'] = $this->mID;
}
- return Html::rawElement( 'td', array( 'class' => 'mw-label' ),
+ return Html::rawElement( 'td', array( 'class' => 'mw-label' ) + $cellAttributes,
Html::rawElement( 'label', $for, $this->getLabel() )
);
}
$attr['disabled'] = 'disabled';
}
- return Xml::check( $this->mName, $value, $attr ) . ' ' .
+ return Xml::check( $this->mName, $value, $attr ) . ' ' .
Html::rawElement( 'label', array( 'for' => $this->mID ), $this->mLabel );
}
* added in getInputHTML(), rather than HTMLFormField::getRow()
*/
function getLabel() {
- return ' ';
+ return ' ';
}
function loadDataFromRequest( $request ) {
$checkbox = Xml::check( $this->mName . '[]', in_array( $info, $value, true ),
$attribs + $thisAttribs );
- $checkbox .= ' ' . Html::rawElement( 'label', array( 'for' => $this->mID . "-$info" ), $label );
+ $checkbox .= ' ' . Html::rawElement( 'label', array( 'for' => $this->mID . "-$info" ), $label );
$html .= $checkbox . '<br />';
}
$info == $value,
$attribs + array( 'id' => $id )
);
- $html .= ' ' .
+ $html .= ' ' .
Html::rawElement( 'label', array( 'for' => $id ), $label );
$html .= "<br />\n";