if ( $disable && !in_array( $name, self::$saveBlacklist ) ) {
$info['disabled'] = 'disabled';
}
- $field = HTMLForm::loadInputFromParameters( $name, $info ); // For validation
- $field->mParent = $dummyForm;
+ $field = HTMLForm::loadInputFromParameters( $name, $info, $dummyForm ); // For validation
$defaultOptions = User::getDefaultOptions();
$globalDefault = isset( $defaultOptions[$name] )
? $defaultOptions[$name]
$this->mUseMultipart = true;
}
- $field = self::loadInputFromParameters( $fieldname, $info );
- // FIXME During field's construct, the parent form isn't available!
- // could add a 'parent' name-value to $info, could add a third parameter.
- $field->mParent = $this;
+ $field = self::loadInputFromParameters( $fieldname, $info, $this );
// vform gets too much space if empty labels generate HTML.
if ( $this->isVForm() ) {
*
* @param string $fieldname Name of the field
* @param array $descriptor Input Descriptor, as described above
+ * @param HTMLForm|null $parent Parent instance of HTMLForm
*
* @throws MWException
* @return HTMLFormField Instance of a subclass of HTMLFormField
*/
- public static function loadInputFromParameters( $fieldname, $descriptor ) {
+ public static function loadInputFromParameters( $fieldname, $descriptor, HTMLForm $parent = null ) {
$class = self::getClassFromDescriptor( $fieldname, $descriptor );
$descriptor['fieldname'] = $fieldname;
+ if ( $parent ) {
+ $descriptor['parent'] = $parent;
+ }
# @todo This will throw a fatal error whenever someone try to use
# 'class' to feed a CSS class instead of 'cssclass'. Would be
function __construct( $params ) {
$this->mParams = $params;
+ if ( isset( $params['parent'] ) && $params['parent'] instanceof HTMLForm ) {
+ $this->mParent = $params['parent'];
+ }
+
# Generate the label from a message, if possible
if ( isset( $params['label-message'] ) ) {
$msgInfo = $params['label-message'];
$msgInfo = array();
}
- $this->mLabel = wfMessage( $msg, $msgInfo )->parse();
+ $this->mLabel = $this->msg( $msg, $msgInfo )->parse();
} elseif ( isset( $params['label'] ) ) {
if ( $params['label'] === ' ' ) {
// Apparently some things set   directly and in an odd format
} else {
$info['id'] = Sanitizer::escapeId( "{$this->mID}--$key--$fieldname" );
}
- $field = HTMLForm::loadInputFromParameters( $name, $info );
- $field->mParent = $this->mParent;
+ $field = HTMLForm::loadInputFromParameters( $name, $info, $this->mParent );
$fields[$fieldname] = $field;
}
return $fields;
'id' => Sanitizer::escapeId( "{$this->mID}--$key--delete" ),
'cssclass' => 'mw-htmlform-cloner-delete-button',
'default' => $this->msg( $label )->text(),
- ) );
- $field->mParent = $this->mParent;
+ ), $this->mParent );
$v = $field->getDefault();
if ( $displayFormat === 'table' ) {
'id' => Sanitizer::escapeId( "{$this->mID}--create" ),
'cssclass' => 'mw-htmlform-cloner-create-button',
'default' => $this->msg( $label )->text(),
- ) );
- $field->mParent = $this->mParent;
+ ), $this->mParent );
$html .= $field->getInputHTML( $field->getDefault() );
return $html;