Allow setting HTMLForm name
authorGergő Tisza <tgr.huwiki@gmail.com>
Fri, 1 Apr 2016 12:08:18 +0000 (15:08 +0300)
committerGergő Tisza <tgr.huwiki@gmail.com>
Fri, 1 Apr 2016 12:22:47 +0000 (15:22 +0300)
Change-Id: I85f5492e0b99a5661dbed9814a0e3f3b9bc63d32

includes/htmlform/HTMLForm.php

index bf46e55..c3aa044 100644 (file)
@@ -180,6 +180,7 @@ class HTMLForm extends ContextSource {
        protected $mSectionFooters = [];
        protected $mPost = '';
        protected $mId;
+       protected $mName;
        protected $mTableId = '';
 
        protected $mSubmitID;
@@ -1006,6 +1007,9 @@ class HTMLForm extends ContextSource {
                if ( !empty( $this->mAutocomplete ) ) {
                        $attribs['autocomplete'] = $this->mAutocomplete;
                }
+               if ( !empty ( $this->mName ) ) {
+                       $attribs['name'] = $this->mName;
+               }
                return $attribs;
        }
 
@@ -1347,6 +1351,16 @@ class HTMLForm extends ContextSource {
                return $this;
        }
 
+       /**
+        * @param string$ name 'name' attribute for the form
+        * @return HTMLForm $this for chaining calls
+        */
+       public function setName( $name ) {
+               $this->mName = $name;
+
+               return $this;
+       }
+
        /**
         * Prompt the whole form to be wrapped in a "<fieldset>", with
         * this text as its "<legend>" element.