protected $mButtons = array();
protected $mWrapperLegend = false;
+
+ /**
+ * If true, sections that contain both fields and subsections will
+ * render their subsections before their fields.
+ *
+ * Subclasses may set this to false to render subsections after fields
+ * instead.
+ */
+ protected $mSubSectionBeforeFields = true;
/**
* Build a new HTMLForm from an array of field attributes
* done already.
* @deprecated since 1.18 load modules with ResourceLoader instead
*/
- static function addJS() { }
+ static function addJS() { wfDeprecated( __METHOD__, '1.18' ); }
/**
* Initialise a new Object for the field
$html = '';
if( $this->getMethod() == 'post' ){
- $html .= Html::hidden( 'wpEditToken', $this->getUser()->editToken(), array( 'id' => 'wpEditToken' ) ) . "\n";
+ $html .= Html::hidden( 'wpEditToken', $this->getUser()->getEditToken(), array( 'id' => 'wpEditToken' ) ) . "\n";
$html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n";
}
$tableHtml = Html::rawElement( 'table', $attribs,
Html::rawElement( 'tbody', array(), "\n$tableHtml\n" ) ) . "\n";
- return $subsectionHtml . "\n" . $tableHtml;
+ if ( $this->mSubSectionBeforeFields ) {
+ return $subsectionHtml . "\n" . $tableHtml;
+ } else {
+ return $tableHtml . "\n" . $subsectionHtml;
+ }
}
/**
}
if ( isset( $this->mValidationCallback ) ) {
- return call_user_func( $this->mValidationCallback, $value, $alldata );
+ return call_user_func( $this->mValidationCallback, $value, $alldata, $this->mParent );
}
return true;
function filter( $value, $alldata ) {
if ( isset( $this->mFilterCallback ) ) {
- $value = call_user_func( $this->mFilterCallback, $value, $alldata );
+ $value = call_user_func( $this->mFilterCallback, $value, $alldata, $this->mParent );
}
return $value;
}
// GetCheck won't work like we want for checks.
- if ( $request->getCheck( 'wpEditToken' ) || $this->mParent->getMethod() != 'post' ) {
+ // Fetch the value in either one of the two following case:
+ // - we have a valid token (form got posted or GET forged by the user)
+ // - checkbox name has a value (false or true), ie is not null
+ if ( $request->getCheck( 'wpEditToken' ) || $request->getVal( $this->mName )!== null ) {
// XOR has the following truth table, which is what we want
// INVERT VALUE | OUTPUT
// true true | false