Html::hidden PHP Method

hidden() static public method

If value of options is an array then recursively parse it to generate as many hidden input as necessary
static public hidden ( $fieldName, $options = [] ) : string
$fieldName Name of a field
$options Array of HTML attributes.
return string A generated hidden input
    static function hidden($fieldName, $options = array())
    {
        if (isset($options['value']) && is_array($options['value'])) {
            $result = '';
            foreach ($options['value'] as $key => $value) {
                $options2 = $options;
                $options2['value'] = $value;
                $result .= static::hidden($fieldName . '[' . $key . ']', $options2) . "\n";
            }
            return $result;
        }
        return sprintf('<input type="hidden" name="%1$s" %2$s />', Html::cleanInputText($fieldName), Html::parseAttributes($options));
    }

Usage Example

 /**
  * Output a form to allow searching for a user
  */
 function switchForm()
 {
     global $wgScript;
     $this->getOutput()->addModules('ext.centralauth.globaluserautocomplete');
     $this->getOutput()->addModuleStyles('mediawiki.special');
     $this->getOutput()->addHTML(Xml::openElement('form', array('method' => 'get', 'action' => $wgScript, 'name' => 'uluser', 'id' => 'mw-userrights-form1')) . Html::hidden('title', $this->getPageTitle()) . Xml::openElement('fieldset') . Xml::element('legend', array(), $this->msg('userrights-lookup-user')->text()) . Xml::inputLabel($this->msg('userrights-user-editname')->text(), 'user', 'username', 30, $this->mTarget, array('class' => 'mw-autocomplete-global-user')) . ' <br />' . Xml::submitButton($this->msg('editusergroup')->text()) . Xml::closeElement('fieldset') . Xml::closeElement('form') . "\n");
 }
All Usage Examples Of Html::hidden
Html