From: Gergő Tisza Date: Mon, 22 Aug 2016 22:24:41 +0000 (+0000) Subject: Expose form field objects in HTMLForm X-Git-Tag: 1.31.0-rc.0~5934^2 X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=commitdiff_plain;h=1abe8200881420e6b3d6d2b9fa42afb58038cf7c;p=lhc%2Fweb%2Fwiklou.git Expose form field objects in HTMLForm Change-Id: Id22c5b9da154d67948ff2b91702a256c25718312 --- diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index ff37e24e2f..3c88594eac 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -354,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 *