X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhtmlform%2FHTMLForm.php;h=3c88594eac7d84e1402f2a88172882ac0fd09df3;hb=2108c55ec531fbf44d0736b2ce5c532d677669da;hp=2b7417e4687f3c5979fd4a825400ac557ca4fb89;hpb=dda1b390620067e065e3a0cd230768eed060ce2f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 2b7417e468..3c88594eac 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -71,6 +71,11 @@ * 'help-messages' -- array of message keys/objects. As above, each item can * be an array of msg key and then parameters. * Overwrites 'help'. + * 'notice' -- message text for a message to use as a notice in the field. + * Currently used by OOUI form fields only. + * 'notice-messages' -- array of message keys/objects to use for notice. + * Overrides 'notice'. + * 'notice-message' -- message key or object to use as a notice. * 'required' -- passed through to the object, indicating that it * is a required field. * 'size' -- the length of text fields @@ -270,14 +275,12 @@ class HTMLForm extends ContextSource { switch ( $displayFormat ) { case 'vform': - $reflector = new ReflectionClass( 'VFormHTMLForm' ); - return $reflector->newInstanceArgs( $arguments ); + return ObjectFactory::constructClassInstance( VFormHTMLForm::class, $arguments ); case 'ooui': - $reflector = new ReflectionClass( 'OOUIHTMLForm' ); - return $reflector->newInstanceArgs( $arguments ); + return ObjectFactory::constructClassInstance( OOUIHTMLForm::class, $arguments ); default: - $reflector = new ReflectionClass( 'HTMLForm' ); - $form = $reflector->newInstanceArgs( $arguments ); + /** @var HTMLForm $form */ + $form = ObjectFactory::constructClassInstance( HTMLForm::class, $arguments ); $form->setDisplayFormat( $displayFormat ); return $form; } @@ -351,6 +354,26 @@ class HTMLForm extends ContextSource { $this->mFieldTree = $loadedDescriptor; } + /** + * @param string $fieldname + * @return bool + */ + public function hasField( $fieldname ) { + return isset( $this->mFlatFields[$fieldname] ); + } + + /** + * @param string $fieldname + * @return HTMLFormField + * @throws DomainException on invalid field name + */ + public function getField( $fieldname ) { + if ( !$this->hasField( $fieldname ) ) { + throw new DomainException( __METHOD__ . ': no field named ' . $fieldname ); + } + return $this->mFlatFields[$fieldname]; + } + /** * Set format in which to display the form *