From 1abe8200881420e6b3d6d2b9fa42afb58038cf7c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerg=C5=91=20Tisza?= Date: Mon, 22 Aug 2016 22:24:41 +0000 Subject: [PATCH] Expose form field objects in HTMLForm Change-Id: Id22c5b9da154d67948ff2b91702a256c25718312 --- includes/htmlform/HTMLForm.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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 * -- 2.20.1