From: Brad Jorsch Date: Mon, 20 Apr 2015 19:57:42 +0000 (-0400) Subject: API: Set HTMLForm when validating field in ApiOptions X-Git-Tag: 1.31.0-rc.0~11410^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/categories/modifier.php?a=commitdiff_plain;h=d2631d1740687e48a28f7b52476d960562a7f25e;p=lhc%2Fweb%2Fwiklou.git API: Set HTMLForm when validating field in ApiOptions Bug: T96583 Change-Id: I09507990827581b587c14b0f7283cdf0dc21436a --- diff --git a/includes/api/ApiOptions.php b/includes/api/ApiOptions.php index 8ef0629928..436f22aee5 100644 --- a/includes/api/ApiOptions.php +++ b/includes/api/ApiOptions.php @@ -75,11 +75,17 @@ class ApiOptions extends ApiBase { $prefs = Preferences::getPreferences( $user, $this->getContext() ); $prefsKinds = $user->getOptionKinds( $this->getContext(), $changes ); + $htmlForm = null; foreach ( $changes as $key => $value ) { switch ( $prefsKinds[$key] ) { case 'registered': // Regular option. + if ( $htmlForm === null ) { + // We need a dummy HTMLForm for the validate callback... + $htmlForm = new HTMLForm( array(), $this ); + } $field = HTMLForm::loadInputFromParameters( $key, $prefs[$key] ); + $field->mParent = $htmlForm; $validation = $field->validate( $value, $user->getOptions() ); break; case 'registered-multiselect':