| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328 | 
							- <?php
 
- /**
 
-  * @link http://www.yiiframework.com/
 
-  * @copyright Copyright (c) 2008 Yii Software LLC
 
-  * @license http://www.yiiframework.com/license/
 
-  */
 
- namespace yii\helpers;
 
- use Yii;
 
- use yii\base\InvalidArgumentException;
 
- use yii\base\Model;
 
- use yii\db\ActiveRecordInterface;
 
- use yii\validators\StringValidator;
 
- use yii\web\Request;
 
- /**
 
-  * BaseHtml provides concrete implementation for [[Html]].
 
-  *
 
-  * Do not use BaseHtml. Use [[Html]] instead.
 
-  *
 
-  * @author Qiang Xue <qiang.xue@gmail.com>
 
-  * @since 2.0
 
-  */
 
- class BaseHtml
 
- {
 
-     /**
 
-      * @var string Regular expression used for attribute name validation.
 
-      * @since 2.0.12
 
-      */
 
-     public static $attributeRegex = '/(^|.*\])([\w\.\+]+)(\[.*|$)/u';
 
-     /**
 
-      * @var array list of void elements (element name => 1)
 
-      * @see http://www.w3.org/TR/html-markup/syntax.html#void-element
 
-      */
 
-     public static $voidElements = [
 
-         'area' => 1,
 
-         'base' => 1,
 
-         'br' => 1,
 
-         'col' => 1,
 
-         'command' => 1,
 
-         'embed' => 1,
 
-         'hr' => 1,
 
-         'img' => 1,
 
-         'input' => 1,
 
-         'keygen' => 1,
 
-         'link' => 1,
 
-         'meta' => 1,
 
-         'param' => 1,
 
-         'source' => 1,
 
-         'track' => 1,
 
-         'wbr' => 1,
 
-     ];
 
-     /**
 
-      * @var array the preferred order of attributes in a tag. This mainly affects the order of the attributes
 
-      * that are rendered by [[renderTagAttributes()]].
 
-      */
 
-     public static $attributeOrder = [
 
-         'type',
 
-         'id',
 
-         'class',
 
-         'name',
 
-         'value',
 
-         'href',
 
-         'src',
 
-         'srcset',
 
-         'form',
 
-         'action',
 
-         'method',
 
-         'selected',
 
-         'checked',
 
-         'readonly',
 
-         'disabled',
 
-         'multiple',
 
-         'size',
 
-         'maxlength',
 
-         'width',
 
-         'height',
 
-         'rows',
 
-         'cols',
 
-         'alt',
 
-         'title',
 
-         'rel',
 
-         'media',
 
-     ];
 
-     /**
 
-      * @var array list of tag attributes that should be specially handled when their values are of array type.
 
-      * In particular, if the value of the `data` attribute is `['name' => 'xyz', 'age' => 13]`, two attributes
 
-      * will be generated instead of one: `data-name="xyz" data-age="13"`.
 
-      * @since 2.0.3
 
-      */
 
-     public static $dataAttributes = ['data', 'data-ng', 'ng'];
 
-     /**
 
-      * Encodes special characters into HTML entities.
 
-      * The [[\yii\base\Application::charset|application charset]] will be used for encoding.
 
-      * @param string $content the content to be encoded
 
-      * @param bool $doubleEncode whether to encode HTML entities in `$content`. If false,
 
-      * HTML entities in `$content` will not be further encoded.
 
-      * @return string the encoded content
 
-      * @see decode()
 
-      * @see https://secure.php.net/manual/en/function.htmlspecialchars.php
 
-      */
 
-     public static function encode($content, $doubleEncode = true)
 
-     {
 
-         return htmlspecialchars($content, ENT_QUOTES | ENT_SUBSTITUTE, Yii::$app ? Yii::$app->charset : 'UTF-8', $doubleEncode);
 
-     }
 
-     /**
 
-      * Decodes special HTML entities back to the corresponding characters.
 
-      * This is the opposite of [[encode()]].
 
-      * @param string $content the content to be decoded
 
-      * @return string the decoded content
 
-      * @see encode()
 
-      * @see https://secure.php.net/manual/en/function.htmlspecialchars-decode.php
 
-      */
 
-     public static function decode($content)
 
-     {
 
-         return htmlspecialchars_decode($content, ENT_QUOTES);
 
-     }
 
-     /**
 
-      * Generates a complete HTML tag.
 
-      * @param string|bool|null $name the tag name. If $name is `null` or `false`, the corresponding content will be rendered without any tag.
 
-      * @param string $content the content to be enclosed between the start and end tags. It will not be HTML-encoded.
 
-      * If this is coming from end users, you should consider [[encode()]] it to prevent XSS attacks.
 
-      * @param array $options the HTML tag attributes (HTML options) in terms of name-value pairs.
 
-      * These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      *
 
-      * For example when using `['class' => 'my-class', 'target' => '_blank', 'value' => null]` it will result in the
 
-      * html attributes rendered like this: `class="my-class" target="_blank"`.
 
-      *
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated HTML tag
 
-      * @see beginTag()
 
-      * @see endTag()
 
-      */
 
-     public static function tag($name, $content = '', $options = [])
 
-     {
 
-         if ($name === null || $name === false) {
 
-             return $content;
 
-         }
 
-         $html = "<$name" . static::renderTagAttributes($options) . '>';
 
-         return isset(static::$voidElements[strtolower($name)]) ? $html : "$html$content</$name>";
 
-     }
 
-     /**
 
-      * Generates a start tag.
 
-      * @param string|bool|null $name the tag name. If $name is `null` or `false`, the corresponding content will be rendered without any tag.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated start tag
 
-      * @see endTag()
 
-      * @see tag()
 
-      */
 
-     public static function beginTag($name, $options = [])
 
-     {
 
-         if ($name === null || $name === false) {
 
-             return '';
 
-         }
 
-         return "<$name" . static::renderTagAttributes($options) . '>';
 
-     }
 
-     /**
 
-      * Generates an end tag.
 
-      * @param string|bool|null $name the tag name. If $name is `null` or `false`, the corresponding content will be rendered without any tag.
 
-      * @return string the generated end tag
 
-      * @see beginTag()
 
-      * @see tag()
 
-      */
 
-     public static function endTag($name)
 
-     {
 
-         if ($name === null || $name === false) {
 
-             return '';
 
-         }
 
-         return "</$name>";
 
-     }
 
-     /**
 
-      * Generates a style tag.
 
-      * @param string $content the style content
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated style tag
 
-      */
 
-     public static function style($content, $options = [])
 
-     {
 
-         return static::tag('style', $content, $options);
 
-     }
 
-     /**
 
-      * Generates a script tag.
 
-      * @param string $content the script content
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated script tag
 
-      */
 
-     public static function script($content, $options = [])
 
-     {
 
-         return static::tag('script', $content, $options);
 
-     }
 
-     /**
 
-      * Generates a link tag that refers to an external CSS file.
 
-      * @param array|string $url the URL of the external CSS file. This parameter will be processed by [[Url::to()]].
 
-      * @param array $options the tag options in terms of name-value pairs. The following options are specially handled:
 
-      *
 
-      * - condition: specifies the conditional comments for IE, e.g., `lt IE 9`. When this is specified,
 
-      *   the generated `link` tag will be enclosed within the conditional comments. This is mainly useful
 
-      *   for supporting old versions of IE browsers.
 
-      * - noscript: if set to true, `link` tag will be wrapped into `<noscript>` tags.
 
-      *
 
-      * The rest of the options will be rendered as the attributes of the resulting link tag. The values will
 
-      * be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated link tag
 
-      * @see Url::to()
 
-      */
 
-     public static function cssFile($url, $options = [])
 
-     {
 
-         if (!isset($options['rel'])) {
 
-             $options['rel'] = 'stylesheet';
 
-         }
 
-         $options['href'] = Url::to($url);
 
-         if (isset($options['condition'])) {
 
-             $condition = $options['condition'];
 
-             unset($options['condition']);
 
-             return self::wrapIntoCondition(static::tag('link', '', $options), $condition);
 
-         } elseif (isset($options['noscript']) && $options['noscript'] === true) {
 
-             unset($options['noscript']);
 
-             return '<noscript>' . static::tag('link', '', $options) . '</noscript>';
 
-         }
 
-         return static::tag('link', '', $options);
 
-     }
 
-     /**
 
-      * Generates a script tag that refers to an external JavaScript file.
 
-      * @param string $url the URL of the external JavaScript file. This parameter will be processed by [[Url::to()]].
 
-      * @param array $options the tag options in terms of name-value pairs. The following option is specially handled:
 
-      *
 
-      * - condition: specifies the conditional comments for IE, e.g., `lt IE 9`. When this is specified,
 
-      *   the generated `script` tag will be enclosed within the conditional comments. This is mainly useful
 
-      *   for supporting old versions of IE browsers.
 
-      *
 
-      * The rest of the options will be rendered as the attributes of the resulting script tag. The values will
 
-      * be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated script tag
 
-      * @see Url::to()
 
-      */
 
-     public static function jsFile($url, $options = [])
 
-     {
 
-         $options['src'] = Url::to($url);
 
-         if (isset($options['condition'])) {
 
-             $condition = $options['condition'];
 
-             unset($options['condition']);
 
-             return self::wrapIntoCondition(static::tag('script', '', $options), $condition);
 
-         }
 
-         return static::tag('script', '', $options);
 
-     }
 
-     /**
 
-      * Wraps given content into conditional comments for IE, e.g., `lt IE 9`.
 
-      * @param string $content raw HTML content.
 
-      * @param string $condition condition string.
 
-      * @return string generated HTML.
 
-      */
 
-     private static function wrapIntoCondition($content, $condition)
 
-     {
 
-         if (strpos($condition, '!IE') !== false) {
 
-             return "<!--[if $condition]><!-->\n" . $content . "\n<!--<![endif]-->";
 
-         }
 
-         return "<!--[if $condition]>\n" . $content . "\n<![endif]-->";
 
-     }
 
-     /**
 
-      * Generates the meta tags containing CSRF token information.
 
-      * @return string the generated meta tags
 
-      * @see Request::enableCsrfValidation
 
-      */
 
-     public static function csrfMetaTags()
 
-     {
 
-         $request = Yii::$app->getRequest();
 
-         if ($request instanceof Request && $request->enableCsrfValidation) {
 
-             return static::tag('meta', '', ['name' => 'csrf-param', 'content' => $request->csrfParam]) . "\n"
 
-                 . static::tag('meta', '', ['name' => 'csrf-token', 'content' => $request->getCsrfToken()]) . "\n";
 
-         }
 
-         return '';
 
-     }
 
-     /**
 
-      * Generates a form start tag.
 
-      * @param array|string $action the form action URL. This parameter will be processed by [[Url::to()]].
 
-      * @param string $method the form submission method, such as "post", "get", "put", "delete" (case-insensitive).
 
-      * Since most browsers only support "post" and "get", if other methods are given, they will
 
-      * be simulated using "post", and a hidden input will be added which contains the actual method type.
 
-      * See [[\yii\web\Request::methodParam]] for more details.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * Special options:
 
-      *
 
-      *  - `csrf`: whether to generate the CSRF hidden input. Defaults to true.
 
-      *
 
-      * @return string the generated form start tag.
 
-      * @see endForm()
 
-      */
 
-     public static function beginForm($action = '', $method = 'post', $options = [])
 
-     {
 
-         $action = Url::to($action);
 
-         $hiddenInputs = [];
 
-         $request = Yii::$app->getRequest();
 
-         if ($request instanceof Request) {
 
-             if (strcasecmp($method, 'get') && strcasecmp($method, 'post')) {
 
-                 // simulate PUT, DELETE, etc. via POST
 
-                 $hiddenInputs[] = static::hiddenInput($request->methodParam, $method);
 
-                 $method = 'post';
 
-             }
 
-             $csrf = ArrayHelper::remove($options, 'csrf', true);
 
-             if ($csrf && $request->enableCsrfValidation && strcasecmp($method, 'post') === 0) {
 
-                 $hiddenInputs[] = static::hiddenInput($request->csrfParam, $request->getCsrfToken());
 
-             }
 
-         }
 
-         if (!strcasecmp($method, 'get') && ($pos = strpos($action, '?')) !== false) {
 
-             // query parameters in the action are ignored for GET method
 
-             // we use hidden fields to add them back
 
-             foreach (explode('&', substr($action, $pos + 1)) as $pair) {
 
-                 if (($pos1 = strpos($pair, '=')) !== false) {
 
-                     $hiddenInputs[] = static::hiddenInput(
 
-                         urldecode(substr($pair, 0, $pos1)),
 
-                         urldecode(substr($pair, $pos1 + 1))
 
-                     );
 
-                 } else {
 
-                     $hiddenInputs[] = static::hiddenInput(urldecode($pair), '');
 
-                 }
 
-             }
 
-             $action = substr($action, 0, $pos);
 
-         }
 
-         $options['action'] = $action;
 
-         $options['method'] = $method;
 
-         $form = static::beginTag('form', $options);
 
-         if (!empty($hiddenInputs)) {
 
-             $form .= "\n" . implode("\n", $hiddenInputs);
 
-         }
 
-         return $form;
 
-     }
 
-     /**
 
-      * Generates a form end tag.
 
-      * @return string the generated tag
 
-      * @see beginForm()
 
-      */
 
-     public static function endForm()
 
-     {
 
-         return '</form>';
 
-     }
 
-     /**
 
-      * Generates a hyperlink tag.
 
-      * @param string $text link body. It will NOT be HTML-encoded. Therefore you can pass in HTML code
 
-      * such as an image tag. If this is coming from end users, you should consider [[encode()]]
 
-      * it to prevent XSS attacks.
 
-      * @param array|string|null $url the URL for the hyperlink tag. This parameter will be processed by [[Url::to()]]
 
-      * and will be used for the "href" attribute of the tag. If this parameter is null, the "href" attribute
 
-      * will not be generated.
 
-      *
 
-      * If you want to use an absolute url you can call [[Url::to()]] yourself, before passing the URL to this method,
 
-      * like this:
 
-      *
 
-      * ```php
 
-      * Html::a('link text', Url::to($url, true))
 
-      * ```
 
-      *
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated hyperlink
 
-      * @see \yii\helpers\Url::to()
 
-      */
 
-     public static function a($text, $url = null, $options = [])
 
-     {
 
-         if ($url !== null) {
 
-             $options['href'] = Url::to($url);
 
-         }
 
-         return static::tag('a', $text, $options);
 
-     }
 
-     /**
 
-      * Generates a mailto hyperlink.
 
-      * @param string $text link body. It will NOT be HTML-encoded. Therefore you can pass in HTML code
 
-      * such as an image tag. If this is coming from end users, you should consider [[encode()]]
 
-      * it to prevent XSS attacks.
 
-      * @param string $email email address. If this is null, the first parameter (link body) will be treated
 
-      * as the email address and used.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated mailto link
 
-      */
 
-     public static function mailto($text, $email = null, $options = [])
 
-     {
 
-         $options['href'] = 'mailto:' . ($email === null ? $text : $email);
 
-         return static::tag('a', $text, $options);
 
-     }
 
-     /**
 
-      * Generates an image tag.
 
-      * @param array|string $src the image URL. This parameter will be processed by [[Url::to()]].
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * Since version 2.0.12 It is possible to pass the `srcset` option as an array which keys are
 
-      * descriptors and values are URLs. All URLs will be processed by [[Url::to()]].
 
-      * @return string the generated image tag.
 
-      */
 
-     public static function img($src, $options = [])
 
-     {
 
-         $options['src'] = Url::to($src);
 
-         if (isset($options['srcset']) && is_array($options['srcset'])) {
 
-             $srcset = [];
 
-             foreach ($options['srcset'] as $descriptor => $url) {
 
-                 $srcset[] = Url::to($url) . ' ' . $descriptor;
 
-             }
 
-             $options['srcset'] = implode(',', $srcset);
 
-         }
 
-         if (!isset($options['alt'])) {
 
-             $options['alt'] = '';
 
-         }
 
-         return static::tag('img', '', $options);
 
-     }
 
-     /**
 
-      * Generates a label tag.
 
-      * @param string $content label text. It will NOT be HTML-encoded. Therefore you can pass in HTML code
 
-      * such as an image tag. If this is is coming from end users, you should [[encode()]]
 
-      * it to prevent XSS attacks.
 
-      * @param string $for the ID of the HTML element that this label is associated with.
 
-      * If this is null, the "for" attribute will not be generated.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated label tag
 
-      */
 
-     public static function label($content, $for = null, $options = [])
 
-     {
 
-         $options['for'] = $for;
 
-         return static::tag('label', $content, $options);
 
-     }
 
-     /**
 
-      * Generates a button tag.
 
-      * @param string $content the content enclosed within the button tag. It will NOT be HTML-encoded.
 
-      * Therefore you can pass in HTML code such as an image tag. If this is is coming from end users,
 
-      * you should consider [[encode()]] it to prevent XSS attacks.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated button tag
 
-      */
 
-     public static function button($content = 'Button', $options = [])
 
-     {
 
-         if (!isset($options['type'])) {
 
-             $options['type'] = 'button';
 
-         }
 
-         return static::tag('button', $content, $options);
 
-     }
 
-     /**
 
-      * Generates a submit button tag.
 
-      *
 
-      * Be careful when naming form elements such as submit buttons. According to the [jQuery documentation](https://api.jquery.com/submit/) there
 
-      * are some reserved names that can cause conflicts, e.g. `submit`, `length`, or `method`.
 
-      *
 
-      * @param string $content the content enclosed within the button tag. It will NOT be HTML-encoded.
 
-      * Therefore you can pass in HTML code such as an image tag. If this is is coming from end users,
 
-      * you should consider [[encode()]] it to prevent XSS attacks.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated submit button tag
 
-      */
 
-     public static function submitButton($content = 'Submit', $options = [])
 
-     {
 
-         $options['type'] = 'submit';
 
-         return static::button($content, $options);
 
-     }
 
-     /**
 
-      * Generates a reset button tag.
 
-      * @param string $content the content enclosed within the button tag. It will NOT be HTML-encoded.
 
-      * Therefore you can pass in HTML code such as an image tag. If this is is coming from end users,
 
-      * you should consider [[encode()]] it to prevent XSS attacks.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated reset button tag
 
-      */
 
-     public static function resetButton($content = 'Reset', $options = [])
 
-     {
 
-         $options['type'] = 'reset';
 
-         return static::button($content, $options);
 
-     }
 
-     /**
 
-      * Generates an input type of the given type.
 
-      * @param string $type the type attribute.
 
-      * @param string $name the name attribute. If it is null, the name attribute will not be generated.
 
-      * @param string $value the value attribute. If it is null, the value attribute will not be generated.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated input tag
 
-      */
 
-     public static function input($type, $name = null, $value = null, $options = [])
 
-     {
 
-         if (!isset($options['type'])) {
 
-             $options['type'] = $type;
 
-         }
 
-         $options['name'] = $name;
 
-         $options['value'] = $value === null ? null : (string) $value;
 
-         return static::tag('input', '', $options);
 
-     }
 
-     /**
 
-      * Generates an input button.
 
-      * @param string $label the value attribute. If it is null, the value attribute will not be generated.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated button tag
 
-      */
 
-     public static function buttonInput($label = 'Button', $options = [])
 
-     {
 
-         $options['type'] = 'button';
 
-         $options['value'] = $label;
 
-         return static::tag('input', '', $options);
 
-     }
 
-     /**
 
-      * Generates a submit input button.
 
-      *
 
-      * Be careful when naming form elements such as submit buttons. According to the [jQuery documentation](https://api.jquery.com/submit/) there
 
-      * are some reserved names that can cause conflicts, e.g. `submit`, `length`, or `method`.
 
-      *
 
-      * @param string $label the value attribute. If it is null, the value attribute will not be generated.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated button tag
 
-      */
 
-     public static function submitInput($label = 'Submit', $options = [])
 
-     {
 
-         $options['type'] = 'submit';
 
-         $options['value'] = $label;
 
-         return static::tag('input', '', $options);
 
-     }
 
-     /**
 
-      * Generates a reset input button.
 
-      * @param string $label the value attribute. If it is null, the value attribute will not be generated.
 
-      * @param array $options the attributes of the button tag. The values will be HTML-encoded using [[encode()]].
 
-      * Attributes whose value is null will be ignored and not put in the tag returned.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated button tag
 
-      */
 
-     public static function resetInput($label = 'Reset', $options = [])
 
-     {
 
-         $options['type'] = 'reset';
 
-         $options['value'] = $label;
 
-         return static::tag('input', '', $options);
 
-     }
 
-     /**
 
-      * Generates a text input field.
 
-      * @param string $name the name attribute.
 
-      * @param string $value the value attribute. If it is null, the value attribute will not be generated.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated text input tag
 
-      */
 
-     public static function textInput($name, $value = null, $options = [])
 
-     {
 
-         return static::input('text', $name, $value, $options);
 
-     }
 
-     /**
 
-      * Generates a hidden input field.
 
-      * @param string $name the name attribute.
 
-      * @param string $value the value attribute. If it is null, the value attribute will not be generated.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated hidden input tag
 
-      */
 
-     public static function hiddenInput($name, $value = null, $options = [])
 
-     {
 
-         return static::input('hidden', $name, $value, $options);
 
-     }
 
-     /**
 
-      * Generates a password input field.
 
-      * @param string $name the name attribute.
 
-      * @param string $value the value attribute. If it is null, the value attribute will not be generated.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated password input tag
 
-      */
 
-     public static function passwordInput($name, $value = null, $options = [])
 
-     {
 
-         return static::input('password', $name, $value, $options);
 
-     }
 
-     /**
 
-      * Generates a file input field.
 
-      * To use a file input field, you should set the enclosing form's "enctype" attribute to
 
-      * be "multipart/form-data". After the form is submitted, the uploaded file information
 
-      * can be obtained via $_FILES[$name] (see PHP documentation).
 
-      * @param string $name the name attribute.
 
-      * @param string $value the value attribute. If it is null, the value attribute will not be generated.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated file input tag
 
-      */
 
-     public static function fileInput($name, $value = null, $options = [])
 
-     {
 
-         return static::input('file', $name, $value, $options);
 
-     }
 
-     /**
 
-      * Generates a text area input.
 
-      * @param string $name the input name
 
-      * @param string $value the input value. Note that it will be encoded using [[encode()]].
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * The following special options are recognized:
 
-      *
 
-      * - `doubleEncode`: whether to double encode HTML entities in `$value`. If `false`, HTML entities in `$value` will not
 
-      *   be further encoded. This option is available since version 2.0.11.
 
-      *
 
-      * @return string the generated text area tag
 
-      */
 
-     public static function textarea($name, $value = '', $options = [])
 
-     {
 
-         $options['name'] = $name;
 
-         $doubleEncode = ArrayHelper::remove($options, 'doubleEncode', true);
 
-         return static::tag('textarea', static::encode($value, $doubleEncode), $options);
 
-     }
 
-     /**
 
-      * Generates a radio button input.
 
-      * @param string $name the name attribute.
 
-      * @param bool $checked whether the radio button should be checked.
 
-      * @param array $options the tag options in terms of name-value pairs.
 
-      * See [[booleanInput()]] for details about accepted attributes.
 
-      *
 
-      * @return string the generated radio button tag
 
-      */
 
-     public static function radio($name, $checked = false, $options = [])
 
-     {
 
-         return static::booleanInput('radio', $name, $checked, $options);
 
-     }
 
-     /**
 
-      * Generates a checkbox input.
 
-      * @param string $name the name attribute.
 
-      * @param bool $checked whether the checkbox should be checked.
 
-      * @param array $options the tag options in terms of name-value pairs.
 
-      * See [[booleanInput()]] for details about accepted attributes.
 
-      *
 
-      * @return string the generated checkbox tag
 
-      */
 
-     public static function checkbox($name, $checked = false, $options = [])
 
-     {
 
-         return static::booleanInput('checkbox', $name, $checked, $options);
 
-     }
 
-     /**
 
-      * Generates a boolean input.
 
-      * @param string $type the input type. This can be either `radio` or `checkbox`.
 
-      * @param string $name the name attribute.
 
-      * @param bool $checked whether the checkbox should be checked.
 
-      * @param array $options the tag options in terms of name-value pairs. The following options are specially handled:
 
-      *
 
-      * - uncheck: string, the value associated with the uncheck state of the checkbox. When this attribute
 
-      *   is present, a hidden input will be generated so that if the checkbox is not checked and is submitted,
 
-      *   the value of this attribute will still be submitted to the server via the hidden input.
 
-      * - label: string, a label displayed next to the checkbox.  It will NOT be HTML-encoded. Therefore you can pass
 
-      *   in HTML code such as an image tag. If this is is coming from end users, you should [[encode()]] it to prevent XSS attacks.
 
-      *   When this option is specified, the checkbox will be enclosed by a label tag.
 
-      * - labelOptions: array, the HTML attributes for the label tag. Do not set this option unless you set the "label" option.
 
-      *
 
-      * The rest of the options will be rendered as the attributes of the resulting checkbox tag. The values will
 
-      * be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated checkbox tag
 
-      * @since 2.0.9
 
-      */
 
-     protected static function booleanInput($type, $name, $checked = false, $options = [])
 
-     {
 
-         // 'checked' option has priority over $checked argument
 
-         if (!isset($options['checked'])) {
 
-             $options['checked'] = (bool) $checked;
 
-         }
 
-         $value = array_key_exists('value', $options) ? $options['value'] : '1';
 
-         if (isset($options['uncheck'])) {
 
-             // add a hidden field so that if the checkbox is not selected, it still submits a value
 
-             $hiddenOptions = [];
 
-             if (isset($options['form'])) {
 
-                 $hiddenOptions['form'] = $options['form'];
 
-             }
 
-             // make sure disabled input is not sending any value
 
-             if (!empty($options['disabled'])) {
 
-                 $hiddenOptions['disabled'] = $options['disabled'];
 
-             }
 
-             $hidden = static::hiddenInput($name, $options['uncheck'], $hiddenOptions);
 
-             unset($options['uncheck']);
 
-         } else {
 
-             $hidden = '';
 
-         }
 
-         if (isset($options['label'])) {
 
-             $label = $options['label'];
 
-             $labelOptions = isset($options['labelOptions']) ? $options['labelOptions'] : [];
 
-             unset($options['label'], $options['labelOptions']);
 
-             $content = static::label(static::input($type, $name, $value, $options) . ' ' . $label, null, $labelOptions);
 
-             return $hidden . $content;
 
-         }
 
-         return $hidden . static::input($type, $name, $value, $options);
 
-     }
 
-     /**
 
-      * Generates a drop-down list.
 
-      * @param string $name the input name
 
-      * @param string|array|null $selection the selected value(s). String for single or array for multiple selection(s).
 
-      * @param array $items the option data items. The array keys are option values, and the array values
 
-      * are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too).
 
-      * For each sub-array, an option group will be generated whose label is the key associated with the sub-array.
 
-      * If you have a list of data models, you may convert them into the format described above using
 
-      * [[\yii\helpers\ArrayHelper::map()]].
 
-      *
 
-      * Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in
 
-      * the labels will also be HTML-encoded.
 
-      * @param array $options the tag options in terms of name-value pairs. The following options are specially handled:
 
-      *
 
-      * - prompt: string, a prompt text to be displayed as the first option. Since version 2.0.11 you can use an array
 
-      *   to override the value and to set other tag attributes:
 
-      *
 
-      *   ```php
 
-      *   ['text' => 'Please select', 'options' => ['value' => 'none', 'class' => 'prompt', 'label' => 'Select']],
 
-      *   ```
 
-      *
 
-      * - options: array, the attributes for the select option tags. The array keys must be valid option values,
 
-      *   and the array values are the extra attributes for the corresponding option tags. For example,
 
-      *
 
-      *   ```php
 
-      *   [
 
-      *       'value1' => ['disabled' => true],
 
-      *       'value2' => ['label' => 'value 2'],
 
-      *   ];
 
-      *   ```
 
-      *
 
-      * - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options',
 
-      *   except that the array keys represent the optgroup labels specified in $items.
 
-      * - encodeSpaces: bool, whether to encode spaces in option prompt and option value with ` ` character.
 
-      *   Defaults to false.
 
-      * - encode: bool, whether to encode option prompt and option value characters.
 
-      *   Defaults to `true`. This option is available since 2.0.3.
 
-      *
 
-      * The rest of the options will be rendered as the attributes of the resulting tag. The values will
 
-      * be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated drop-down list tag
 
-      */
 
-     public static function dropDownList($name, $selection = null, $items = [], $options = [])
 
-     {
 
-         if (!empty($options['multiple'])) {
 
-             return static::listBox($name, $selection, $items, $options);
 
-         }
 
-         $options['name'] = $name;
 
-         unset($options['unselect']);
 
-         $selectOptions = static::renderSelectOptions($selection, $items, $options);
 
-         return static::tag('select', "\n" . $selectOptions . "\n", $options);
 
-     }
 
-     /**
 
-      * Generates a list box.
 
-      * @param string $name the input name
 
-      * @param string|array|null $selection the selected value(s). String for single or array for multiple selection(s).
 
-      * @param array $items the option data items. The array keys are option values, and the array values
 
-      * are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too).
 
-      * For each sub-array, an option group will be generated whose label is the key associated with the sub-array.
 
-      * If you have a list of data models, you may convert them into the format described above using
 
-      * [[\yii\helpers\ArrayHelper::map()]].
 
-      *
 
-      * Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in
 
-      * the labels will also be HTML-encoded.
 
-      * @param array $options the tag options in terms of name-value pairs. The following options are specially handled:
 
-      *
 
-      * - prompt: string, a prompt text to be displayed as the first option. Since version 2.0.11 you can use an array
 
-      *   to override the value and to set other tag attributes:
 
-      *
 
-      *   ```php
 
-      *   ['text' => 'Please select', 'options' => ['value' => 'none', 'class' => 'prompt', 'label' => 'Select']],
 
-      *   ```
 
-      *
 
-      * - options: array, the attributes for the select option tags. The array keys must be valid option values,
 
-      *   and the array values are the extra attributes for the corresponding option tags. For example,
 
-      *
 
-      *   ```php
 
-      *   [
 
-      *       'value1' => ['disabled' => true],
 
-      *       'value2' => ['label' => 'value 2'],
 
-      *   ];
 
-      *   ```
 
-      *
 
-      * - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options',
 
-      *   except that the array keys represent the optgroup labels specified in $items.
 
-      * - unselect: string, the value that will be submitted when no option is selected.
 
-      *   When this attribute is set, a hidden field will be generated so that if no option is selected in multiple
 
-      *   mode, we can still obtain the posted unselect value.
 
-      * - encodeSpaces: bool, whether to encode spaces in option prompt and option value with ` ` character.
 
-      *   Defaults to false.
 
-      * - encode: bool, whether to encode option prompt and option value characters.
 
-      *   Defaults to `true`. This option is available since 2.0.3.
 
-      *
 
-      * The rest of the options will be rendered as the attributes of the resulting tag. The values will
 
-      * be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated list box tag
 
-      */
 
-     public static function listBox($name, $selection = null, $items = [], $options = [])
 
-     {
 
-         if (!array_key_exists('size', $options)) {
 
-             $options['size'] = 4;
 
-         }
 
-         if (!empty($options['multiple']) && !empty($name) && substr_compare($name, '[]', -2, 2)) {
 
-             $name .= '[]';
 
-         }
 
-         $options['name'] = $name;
 
-         if (isset($options['unselect'])) {
 
-             // add a hidden field so that if the list box has no option being selected, it still submits a value
 
-             if (!empty($name) && substr_compare($name, '[]', -2, 2) === 0) {
 
-                 $name = substr($name, 0, -2);
 
-             }
 
-             $hiddenOptions = [];
 
-             // make sure disabled input is not sending any value
 
-             if (!empty($options['disabled'])) {
 
-                 $hiddenOptions['disabled'] = $options['disabled'];
 
-             }
 
-             $hidden = static::hiddenInput($name, $options['unselect'], $hiddenOptions);
 
-             unset($options['unselect']);
 
-         } else {
 
-             $hidden = '';
 
-         }
 
-         $selectOptions = static::renderSelectOptions($selection, $items, $options);
 
-         return $hidden . static::tag('select', "\n" . $selectOptions . "\n", $options);
 
-     }
 
-     /**
 
-      * Generates a list of checkboxes.
 
-      * A checkbox list allows multiple selection, like [[listBox()]].
 
-      * As a result, the corresponding submitted value is an array.
 
-      * @param string $name the name attribute of each checkbox.
 
-      * @param string|array|null $selection the selected value(s). String for single or array for multiple selection(s).
 
-      * @param array $items the data item used to generate the checkboxes.
 
-      * The array keys are the checkbox values, while the array values are the corresponding labels.
 
-      * @param array $options options (name => config) for the checkbox list container tag.
 
-      * The following options are specially handled:
 
-      *
 
-      * - tag: string|false, the tag name of the container element. False to render checkbox without container.
 
-      *   See also [[tag()]].
 
-      * - unselect: string, the value that should be submitted when none of the checkboxes is selected.
 
-      *   By setting this option, a hidden input will be generated.
 
-      * - disabled: boolean, whether the generated by unselect option hidden input should be disabled. Defaults to false.
 
-      *   This option is available since version 2.0.16.
 
-      * - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to true.
 
-      *   This option is ignored if `item` option is set.
 
-      * - separator: string, the HTML code that separates items.
 
-      * - itemOptions: array, the options for generating the checkbox tag using [[checkbox()]].
 
-      * - item: callable, a callback that can be used to customize the generation of the HTML code
 
-      *   corresponding to a single item in $items. The signature of this callback must be:
 
-      *
 
-      *   ```php
 
-      *   function ($index, $label, $name, $checked, $value)
 
-      *   ```
 
-      *
 
-      *   where $index is the zero-based index of the checkbox in the whole list; $label
 
-      *   is the label for the checkbox; and $name, $value and $checked represent the name,
 
-      *   value and the checked status of the checkbox input, respectively.
 
-      *
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated checkbox list
 
-      */
 
-     public static function checkboxList($name, $selection = null, $items = [], $options = [])
 
-     {
 
-         if (substr($name, -2) !== '[]') {
 
-             $name .= '[]';
 
-         }
 
-         if (ArrayHelper::isTraversable($selection)) {
 
-             $selection = array_map('strval', (array)$selection);
 
-         }
 
-         $formatter = ArrayHelper::remove($options, 'item');
 
-         $itemOptions = ArrayHelper::remove($options, 'itemOptions', []);
 
-         $encode = ArrayHelper::remove($options, 'encode', true);
 
-         $separator = ArrayHelper::remove($options, 'separator', "\n");
 
-         $tag = ArrayHelper::remove($options, 'tag', 'div');
 
-         $lines = [];
 
-         $index = 0;
 
-         foreach ($items as $value => $label) {
 
-             $checked = $selection !== null &&
 
-                 (!ArrayHelper::isTraversable($selection) && !strcmp($value, $selection)
 
-                     || ArrayHelper::isTraversable($selection) && ArrayHelper::isIn((string)$value, $selection));
 
-             if ($formatter !== null) {
 
-                 $lines[] = call_user_func($formatter, $index, $label, $name, $checked, $value);
 
-             } else {
 
-                 $lines[] = static::checkbox($name, $checked, array_merge([
 
-                     'value' => $value,
 
-                     'label' => $encode ? static::encode($label) : $label,
 
-                 ], $itemOptions));
 
-             }
 
-             $index++;
 
-         }
 
-         if (isset($options['unselect'])) {
 
-             // add a hidden field so that if the list box has no option being selected, it still submits a value
 
-             $name2 = substr($name, -2) === '[]' ? substr($name, 0, -2) : $name;
 
-             $hiddenOptions = [];
 
-             // make sure disabled input is not sending any value
 
-             if (!empty($options['disabled'])) {
 
-                 $hiddenOptions['disabled'] = $options['disabled'];
 
-             }
 
-             $hidden = static::hiddenInput($name2, $options['unselect'], $hiddenOptions);
 
-             unset($options['unselect'], $options['disabled']);
 
-         } else {
 
-             $hidden = '';
 
-         }
 
-         $visibleContent = implode($separator, $lines);
 
-         if ($tag === false) {
 
-             return $hidden . $visibleContent;
 
-         }
 
-         return $hidden . static::tag($tag, $visibleContent, $options);
 
-     }
 
-     /**
 
-      * Generates a list of radio buttons.
 
-      * A radio button list is like a checkbox list, except that it only allows single selection.
 
-      * @param string $name the name attribute of each radio button.
 
-      * @param string|array|null $selection the selected value(s). String for single or array for multiple selection(s).
 
-      * @param array $items the data item used to generate the radio buttons.
 
-      * The array keys are the radio button values, while the array values are the corresponding labels.
 
-      * @param array $options options (name => config) for the radio button list container tag.
 
-      * The following options are specially handled:
 
-      *
 
-      * - tag: string|false, the tag name of the container element. False to render radio buttons without container.
 
-      *   See also [[tag()]].
 
-      * - unselect: string, the value that should be submitted when none of the radio buttons is selected.
 
-      *   By setting this option, a hidden input will be generated.
 
-      * - disabled: boolean, whether the generated by unselect option hidden input should be disabled. Defaults to false.
 
-      *   This option is available since version 2.0.16.
 
-      * - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to true.
 
-      *   This option is ignored if `item` option is set.
 
-      * - separator: string, the HTML code that separates items.
 
-      * - itemOptions: array, the options for generating the radio button tag using [[radio()]].
 
-      * - item: callable, a callback that can be used to customize the generation of the HTML code
 
-      *   corresponding to a single item in $items. The signature of this callback must be:
 
-      *
 
-      *   ```php
 
-      *   function ($index, $label, $name, $checked, $value)
 
-      *   ```
 
-      *
 
-      *   where $index is the zero-based index of the radio button in the whole list; $label
 
-      *   is the label for the radio button; and $name, $value and $checked represent the name,
 
-      *   value and the checked status of the radio button input, respectively.
 
-      *
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated radio button list
 
-      */
 
-     public static function radioList($name, $selection = null, $items = [], $options = [])
 
-     {
 
-         if (ArrayHelper::isTraversable($selection)) {
 
-             $selection = array_map('strval', (array)$selection);
 
-         }
 
-         $formatter = ArrayHelper::remove($options, 'item');
 
-         $itemOptions = ArrayHelper::remove($options, 'itemOptions', []);
 
-         $encode = ArrayHelper::remove($options, 'encode', true);
 
-         $separator = ArrayHelper::remove($options, 'separator', "\n");
 
-         $tag = ArrayHelper::remove($options, 'tag', 'div');
 
-         $hidden = '';
 
-         if (isset($options['unselect'])) {
 
-             // add a hidden field so that if the list box has no option being selected, it still submits a value
 
-             $hiddenOptions = [];
 
-             // make sure disabled input is not sending any value
 
-             if (!empty($options['disabled'])) {
 
-                 $hiddenOptions['disabled'] = $options['disabled'];
 
-             }
 
-             $hidden =  static::hiddenInput($name, $options['unselect'], $hiddenOptions);
 
-             unset($options['unselect'], $options['disabled']);
 
-         }
 
-         $lines = [];
 
-         $index = 0;
 
-         foreach ($items as $value => $label) {
 
-             $checked = $selection !== null &&
 
-                 (!ArrayHelper::isTraversable($selection) && !strcmp($value, $selection)
 
-                     || ArrayHelper::isTraversable($selection) && ArrayHelper::isIn((string)$value, $selection));
 
-             if ($formatter !== null) {
 
-                 $lines[] = call_user_func($formatter, $index, $label, $name, $checked, $value);
 
-             } else {
 
-                 $lines[] = static::radio($name, $checked, array_merge([
 
-                     'value' => $value,
 
-                     'label' => $encode ? static::encode($label) : $label,
 
-                 ], $itemOptions));
 
-             }
 
-             $index++;
 
-         }
 
-         $visibleContent = implode($separator, $lines);
 
-         if ($tag === false) {
 
-             return $hidden . $visibleContent;
 
-         }
 
-         return $hidden . static::tag($tag, $visibleContent, $options);
 
-     }
 
-     /**
 
-      * Generates an unordered list.
 
-      * @param array|\Traversable $items the items for generating the list. Each item generates a single list item.
 
-      * Note that items will be automatically HTML encoded if `$options['encode']` is not set or true.
 
-      * @param array $options options (name => config) for the radio button list. The following options are supported:
 
-      *
 
-      * - encode: boolean, whether to HTML-encode the items. Defaults to true.
 
-      *   This option is ignored if the `item` option is specified.
 
-      * - separator: string, the HTML code that separates items. Defaults to a simple newline (`"\n"`).
 
-      *   This option is available since version 2.0.7.
 
-      * - itemOptions: array, the HTML attributes for the `li` tags. This option is ignored if the `item` option is specified.
 
-      * - item: callable, a callback that is used to generate each individual list item.
 
-      *   The signature of this callback must be:
 
-      *
 
-      *   ```php
 
-      *   function ($item, $index)
 
-      *   ```
 
-      *
 
-      *   where $index is the array key corresponding to `$item` in `$items`. The callback should return
 
-      *   the whole list item tag.
 
-      *
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated unordered list. An empty list tag will be returned if `$items` is empty.
 
-      */
 
-     public static function ul($items, $options = [])
 
-     {
 
-         $tag = ArrayHelper::remove($options, 'tag', 'ul');
 
-         $encode = ArrayHelper::remove($options, 'encode', true);
 
-         $formatter = ArrayHelper::remove($options, 'item');
 
-         $separator = ArrayHelper::remove($options, 'separator', "\n");
 
-         $itemOptions = ArrayHelper::remove($options, 'itemOptions', []);
 
-         if (empty($items)) {
 
-             return static::tag($tag, '', $options);
 
-         }
 
-         $results = [];
 
-         foreach ($items as $index => $item) {
 
-             if ($formatter !== null) {
 
-                 $results[] = call_user_func($formatter, $item, $index);
 
-             } else {
 
-                 $results[] = static::tag('li', $encode ? static::encode($item) : $item, $itemOptions);
 
-             }
 
-         }
 
-         return static::tag(
 
-             $tag,
 
-             $separator . implode($separator, $results) . $separator,
 
-             $options
 
-         );
 
-     }
 
-     /**
 
-      * Generates an ordered list.
 
-      * @param array|\Traversable $items the items for generating the list. Each item generates a single list item.
 
-      * Note that items will be automatically HTML encoded if `$options['encode']` is not set or true.
 
-      * @param array $options options (name => config) for the radio button list. The following options are supported:
 
-      *
 
-      * - encode: boolean, whether to HTML-encode the items. Defaults to true.
 
-      *   This option is ignored if the `item` option is specified.
 
-      * - itemOptions: array, the HTML attributes for the `li` tags. This option is ignored if the `item` option is specified.
 
-      * - item: callable, a callback that is used to generate each individual list item.
 
-      *   The signature of this callback must be:
 
-      *
 
-      *   ```php
 
-      *   function ($item, $index)
 
-      *   ```
 
-      *
 
-      *   where $index is the array key corresponding to `$item` in `$items`. The callback should return
 
-      *   the whole list item tag.
 
-      *
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated ordered list. An empty string is returned if `$items` is empty.
 
-      */
 
-     public static function ol($items, $options = [])
 
-     {
 
-         $options['tag'] = 'ol';
 
-         return static::ul($items, $options);
 
-     }
 
-     /**
 
-      * Generates a label tag for the given model attribute.
 
-      * The label text is the label associated with the attribute, obtained via [[Model::getAttributeLabel()]].
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * The following options are specially handled:
 
-      *
 
-      * - label: this specifies the label to be displayed. Note that this will NOT be [[encode()|encoded]].
 
-      *   If this is not set, [[Model::getAttributeLabel()]] will be called to get the label for display
 
-      *   (after encoding).
 
-      *
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated label tag
 
-      */
 
-     public static function activeLabel($model, $attribute, $options = [])
 
-     {
 
-         $for = ArrayHelper::remove($options, 'for', static::getInputId($model, $attribute));
 
-         $attribute = static::getAttributeName($attribute);
 
-         $label = ArrayHelper::remove($options, 'label', static::encode($model->getAttributeLabel($attribute)));
 
-         return static::label($label, $for, $options);
 
-     }
 
-     /**
 
-      * Generates a hint tag for the given model attribute.
 
-      * The hint text is the hint associated with the attribute, obtained via [[Model::getAttributeHint()]].
 
-      * If no hint content can be obtained, method will return an empty string.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * If a value is null, the corresponding attribute will not be rendered.
 
-      * The following options are specially handled:
 
-      *
 
-      * - hint: this specifies the hint to be displayed. Note that this will NOT be [[encode()|encoded]].
 
-      *   If this is not set, [[Model::getAttributeHint()]] will be called to get the hint for display
 
-      *   (without encoding).
 
-      *
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated hint tag
 
-      * @since 2.0.4
 
-      */
 
-     public static function activeHint($model, $attribute, $options = [])
 
-     {
 
-         $attribute = static::getAttributeName($attribute);
 
-         $hint = isset($options['hint']) ? $options['hint'] : $model->getAttributeHint($attribute);
 
-         if (empty($hint)) {
 
-             return '';
 
-         }
 
-         $tag = ArrayHelper::remove($options, 'tag', 'div');
 
-         unset($options['hint']);
 
-         return static::tag($tag, $hint, $options);
 
-     }
 
-     /**
 
-      * Generates a summary of the validation errors.
 
-      * If there is no validation error, an empty error summary markup will still be generated, but it will be hidden.
 
-      * @param Model|Model[] $models the model(s) whose validation errors are to be displayed.
 
-      * @param array $options the tag options in terms of name-value pairs. The following options are specially handled:
 
-      *
 
-      * - header: string, the header HTML for the error summary. If not set, a default prompt string will be used.
 
-      * - footer: string, the footer HTML for the error summary. Defaults to empty string.
 
-      * - encode: boolean, if set to false then the error messages won't be encoded. Defaults to `true`.
 
-      * - showAllErrors: boolean, if set to true every error message for each attribute will be shown otherwise
 
-      *   only the first error message for each attribute will be shown. Defaults to `false`.
 
-      *   Option is available since 2.0.10.
 
-      *
 
-      * The rest of the options will be rendered as the attributes of the container tag.
 
-      *
 
-      * @return string the generated error summary
 
-      */
 
-     public static function errorSummary($models, $options = [])
 
-     {
 
-         $header = isset($options['header']) ? $options['header'] : '<p>' . Yii::t('yii', 'Please fix the following errors:') . '</p>';
 
-         $footer = ArrayHelper::remove($options, 'footer', '');
 
-         $encode = ArrayHelper::remove($options, 'encode', true);
 
-         $showAllErrors = ArrayHelper::remove($options, 'showAllErrors', false);
 
-         unset($options['header']);
 
-         $lines = self::collectErrors($models, $encode, $showAllErrors);
 
-         if (empty($lines)) {
 
-             // still render the placeholder for client-side validation use
 
-             $content = '<ul></ul>';
 
-             $options['style'] = isset($options['style']) ? rtrim($options['style'], ';') . '; display:none' : 'display:none';
 
-         } else {
 
-             $content = '<ul><li>' . implode("</li>\n<li>", $lines) . '</li></ul>';
 
-         }
 
-         return Html::tag('div', $header . $content . $footer, $options);
 
-     }
 
-     /**
 
-      * Return array of the validation errors
 
-      * @param Model|Model[] $models the model(s) whose validation errors are to be displayed.
 
-      * @param $encode boolean, if set to false then the error messages won't be encoded.
 
-      * @param $showAllErrors boolean, if set to true every error message for each attribute will be shown otherwise
 
-      * only the first error message for each attribute will be shown.
 
-      * @return array of the validation errors
 
-      * @since 2.0.14
 
-      */
 
-     private static function collectErrors($models, $encode, $showAllErrors)
 
-     {
 
-         $lines = [];
 
-         if (!is_array($models)) {
 
-             $models = [$models];
 
-         }
 
-         foreach ($models as $model) {
 
-             $lines = array_unique(array_merge($lines, $model->getErrorSummary($showAllErrors)));
 
-         }
 
-         // If there are the same error messages for different attributes, array_unique will leave gaps
 
-         // between sequential keys. Applying array_values to reorder array keys.
 
-         $lines = array_values($lines);
 
-         if ($encode) {
 
-             foreach ($lines as &$line) {
 
-                 $line = Html::encode($line);
 
-             }
 
-         }
 
-         return $lines;
 
-     }
 
-     /**
 
-      * Generates a tag that contains the first validation error of the specified model attribute.
 
-      * Note that even if there is no validation error, this method will still return an empty error tag.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $options the tag options in terms of name-value pairs. The values will be HTML-encoded
 
-      * using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
 
-      *
 
-      * The following options are specially handled:
 
-      *
 
-      * - tag: this specifies the tag name. If not set, "div" will be used.
 
-      *   See also [[tag()]].
 
-      * - encode: boolean, if set to false then the error message won't be encoded.
 
-      * - errorSource (since 2.0.14): \Closure|callable, callback that will be called to obtain an error message.
 
-      *   The signature of the callback must be: `function ($model, $attribute)` and return a string.
 
-      *   When not set, the `$model->getFirstError()` method will be called.
 
-      *
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated label tag
 
-      */
 
-     public static function error($model, $attribute, $options = [])
 
-     {
 
-         $attribute = static::getAttributeName($attribute);
 
-         $errorSource = ArrayHelper::remove($options, 'errorSource');
 
-         if ($errorSource !== null) {
 
-             $error = call_user_func($errorSource, $model, $attribute);
 
-         } else {
 
-             $error = $model->getFirstError($attribute);
 
-         }
 
-         $tag = ArrayHelper::remove($options, 'tag', 'div');
 
-         $encode = ArrayHelper::remove($options, 'encode', true);
 
-         return Html::tag($tag, $encode ? Html::encode($error) : $error, $options);
 
-     }
 
-     /**
 
-      * Generates an input tag for the given model attribute.
 
-      * This method will generate the "name" and "value" tag attributes automatically for the model attribute
 
-      * unless they are explicitly specified in `$options`.
 
-      * @param string $type the input type (e.g. 'text', 'password')
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated input tag
 
-      */
 
-     public static function activeInput($type, $model, $attribute, $options = [])
 
-     {
 
-         $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);
 
-         $value = isset($options['value']) ? $options['value'] : static::getAttributeValue($model, $attribute);
 
-         if (!array_key_exists('id', $options)) {
 
-             $options['id'] = static::getInputId($model, $attribute);
 
-         }
 
-         static::setActivePlaceholder($model, $attribute, $options);
 
-         self::normalizeMaxLength($model, $attribute, $options);
 
-         return static::input($type, $name, $value, $options);
 
-     }
 
-     /**
 
-      * If `maxlength` option is set true and the model attribute is validated by a string validator,
 
-      * the `maxlength` option will take the value of [[\yii\validators\StringValidator::max]].
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression.
 
-      * @param array $options the tag options in terms of name-value pairs.
 
-      */
 
-     private static function normalizeMaxLength($model, $attribute, &$options)
 
-     {
 
-         if (isset($options['maxlength']) && $options['maxlength'] === true) {
 
-             unset($options['maxlength']);
 
-             $attrName = static::getAttributeName($attribute);
 
-             foreach ($model->getActiveValidators($attrName) as $validator) {
 
-                 if ($validator instanceof StringValidator && $validator->max !== null) {
 
-                     $options['maxlength'] = $validator->max;
 
-                     break;
 
-                 }
 
-             }
 
-         }
 
-     }
 
-     /**
 
-      * Generates a text input tag for the given model attribute.
 
-      * This method will generate the "name" and "value" tag attributes automatically for the model attribute
 
-      * unless they are explicitly specified in `$options`.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * The following special options are recognized:
 
-      *
 
-      * - maxlength: integer|boolean, when `maxlength` is set true and the model attribute is validated
 
-      *   by a string validator, the `maxlength` option will take the value of [[\yii\validators\StringValidator::max]].
 
-      *   This is available since version 2.0.3.
 
-      * - placeholder: string|boolean, when `placeholder` equals `true`, the attribute label from the $model will be used
 
-      *   as a placeholder (this behavior is available since version 2.0.14).
 
-      *
 
-      * @return string the generated input tag
 
-      */
 
-     public static function activeTextInput($model, $attribute, $options = [])
 
-     {
 
-         return static::activeInput('text', $model, $attribute, $options);
 
-     }
 
-     /**
 
-      * Generate placeholder from model attribute label.
 
-      *
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * @since 2.0.14
 
-      */
 
-     protected static function setActivePlaceholder($model, $attribute, &$options = [])
 
-     {
 
-         if (isset($options['placeholder']) && $options['placeholder'] === true) {
 
-             $attribute = static::getAttributeName($attribute);
 
-             $options['placeholder'] = $model->getAttributeLabel($attribute);
 
-         }
 
-     }
 
-     /**
 
-      * Generates a hidden input tag for the given model attribute.
 
-      * This method will generate the "name" and "value" tag attributes automatically for the model attribute
 
-      * unless they are explicitly specified in `$options`.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * @return string the generated input tag
 
-      */
 
-     public static function activeHiddenInput($model, $attribute, $options = [])
 
-     {
 
-         return static::activeInput('hidden', $model, $attribute, $options);
 
-     }
 
-     /**
 
-      * Generates a password input tag for the given model attribute.
 
-      * This method will generate the "name" and "value" tag attributes automatically for the model attribute
 
-      * unless they are explicitly specified in `$options`.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * The following special options are recognized:
 
-      *
 
-      * - maxlength: integer|boolean, when `maxlength` is set true and the model attribute is validated
 
-      *   by a string validator, the `maxlength` option will take the value of [[\yii\validators\StringValidator::max]].
 
-      *   This option is available since version 2.0.6.
 
-      * - placeholder: string|boolean, when `placeholder` equals `true`, the attribute label from the $model will be used
 
-      *   as a placeholder (this behavior is available since version 2.0.14).
 
-      *
 
-      * @return string the generated input tag
 
-      */
 
-     public static function activePasswordInput($model, $attribute, $options = [])
 
-     {
 
-         return static::activeInput('password', $model, $attribute, $options);
 
-     }
 
-     /**
 
-      * Generates a file input tag for the given model attribute.
 
-      * This method will generate the "name" and "value" tag attributes automatically for the model attribute
 
-      * unless they are explicitly specified in `$options`.
 
-      * Additionally, if a separate set of HTML options array is defined inside `$options` with a key named `hiddenOptions`,
 
-      * it will be passed to the `activeHiddenInput` field as its own `$options` parameter.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * If `hiddenOptions` parameter which is another set of HTML options array is defined, it will be extracted
 
-      * from `$options` to be used for the hidden input.
 
-      * @return string the generated input tag
 
-      */
 
-     public static function activeFileInput($model, $attribute, $options = [])
 
-     {
 
-         $hiddenOptions = ['id' => null, 'value' => ''];
 
-         if (isset($options['name'])) {
 
-             $hiddenOptions['name'] = $options['name'];
 
-         }
 
-         // make sure disabled input is not sending any value
 
-         if (!empty($options['disabled'])) {
 
-             $hiddenOptions['disabled'] = $options['disabled'];
 
-         }
 
-         $hiddenOptions = ArrayHelper::merge($hiddenOptions, ArrayHelper::remove($options, 'hiddenOptions', []));
 
-         // Add a hidden field so that if a model only has a file field, we can
 
-         // still use isset($_POST[$modelClass]) to detect if the input is submitted.
 
-         // The hidden input will be assigned its own set of html options via `$hiddenOptions`.
 
-         // This provides the possibility to interact with the hidden field via client script.
 
-         // Note: For file-field-only model with `disabled` option set to `true` input submitting detection won't work.
 
-         return static::activeHiddenInput($model, $attribute, $hiddenOptions)
 
-             . static::activeInput('file', $model, $attribute, $options);
 
-     }
 
-     /**
 
-      * Generates a textarea tag for the given model attribute.
 
-      * The model attribute value will be used as the content in the textarea.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $options the tag options in terms of name-value pairs. These will be rendered as
 
-      * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      * The following special options are recognized:
 
-      *
 
-      * - maxlength: integer|boolean, when `maxlength` is set true and the model attribute is validated
 
-      *   by a string validator, the `maxlength` option will take the value of [[\yii\validators\StringValidator::max]].
 
-      *   This option is available since version 2.0.6.
 
-      * - placeholder: string|boolean, when `placeholder` equals `true`, the attribute label from the $model will be used
 
-      *   as a placeholder (this behavior is available since version 2.0.14).
 
-      *
 
-      * @return string the generated textarea tag
 
-      */
 
-     public static function activeTextarea($model, $attribute, $options = [])
 
-     {
 
-         $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);
 
-         if (isset($options['value'])) {
 
-             $value = $options['value'];
 
-             unset($options['value']);
 
-         } else {
 
-             $value = static::getAttributeValue($model, $attribute);
 
-         }
 
-         if (!array_key_exists('id', $options)) {
 
-             $options['id'] = static::getInputId($model, $attribute);
 
-         }
 
-         self::normalizeMaxLength($model, $attribute, $options);
 
-         static::setActivePlaceholder($model, $attribute, $options);
 
-         return static::textarea($name, $value, $options);
 
-     }
 
-     /**
 
-      * Generates a radio button tag together with a label for the given model attribute.
 
-      * This method will generate the "checked" tag attribute according to the model attribute value.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $options the tag options in terms of name-value pairs.
 
-      * See [[booleanInput()]] for details about accepted attributes.
 
-      *
 
-      * @return string the generated radio button tag
 
-      */
 
-     public static function activeRadio($model, $attribute, $options = [])
 
-     {
 
-         return static::activeBooleanInput('radio', $model, $attribute, $options);
 
-     }
 
-     /**
 
-      * Generates a checkbox tag together with a label for the given model attribute.
 
-      * This method will generate the "checked" tag attribute according to the model attribute value.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $options the tag options in terms of name-value pairs.
 
-      * See [[booleanInput()]] for details about accepted attributes.
 
-      *
 
-      * @return string the generated checkbox tag
 
-      */
 
-     public static function activeCheckbox($model, $attribute, $options = [])
 
-     {
 
-         return static::activeBooleanInput('checkbox', $model, $attribute, $options);
 
-     }
 
-     /**
 
-      * Generates a boolean input
 
-      * This method is mainly called by [[activeCheckbox()]] and [[activeRadio()]].
 
-      * @param string $type the input type. This can be either `radio` or `checkbox`.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $options the tag options in terms of name-value pairs.
 
-      * See [[booleanInput()]] for details about accepted attributes.
 
-      * @return string the generated input element
 
-      * @since 2.0.9
 
-      */
 
-     protected static function activeBooleanInput($type, $model, $attribute, $options = [])
 
-     {
 
-         $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);
 
-         $value = static::getAttributeValue($model, $attribute);
 
-         if (!array_key_exists('value', $options)) {
 
-             $options['value'] = '1';
 
-         }
 
-         if (!array_key_exists('uncheck', $options)) {
 
-             $options['uncheck'] = '0';
 
-         } elseif ($options['uncheck'] === false) {
 
-             unset($options['uncheck']);
 
-         }
 
-         if (!array_key_exists('label', $options)) {
 
-             $options['label'] = static::encode($model->getAttributeLabel(static::getAttributeName($attribute)));
 
-         } elseif ($options['label'] === false) {
 
-             unset($options['label']);
 
-         }
 
-         $checked = "$value" === "{$options['value']}";
 
-         if (!array_key_exists('id', $options)) {
 
-             $options['id'] = static::getInputId($model, $attribute);
 
-         }
 
-         return static::$type($name, $checked, $options);
 
-     }
 
-     /**
 
-      * Generates a drop-down list for the given model attribute.
 
-      * The selection of the drop-down list is taken from the value of the model attribute.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $items the option data items. The array keys are option values, and the array values
 
-      * are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too).
 
-      * For each sub-array, an option group will be generated whose label is the key associated with the sub-array.
 
-      * If you have a list of data models, you may convert them into the format described above using
 
-      * [[\yii\helpers\ArrayHelper::map()]].
 
-      *
 
-      * Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in
 
-      * the labels will also be HTML-encoded.
 
-      * @param array $options the tag options in terms of name-value pairs. The following options are specially handled:
 
-      *
 
-      * - prompt: string, a prompt text to be displayed as the first option. Since version 2.0.11 you can use an array
 
-      *   to override the value and to set other tag attributes:
 
-      *
 
-      *   ```php
 
-      *   ['text' => 'Please select', 'options' => ['value' => 'none', 'class' => 'prompt', 'label' => 'Select']],
 
-      *   ```
 
-      *
 
-      * - options: array, the attributes for the select option tags. The array keys must be valid option values,
 
-      *   and the array values are the extra attributes for the corresponding option tags. For example,
 
-      *
 
-      *   ```php
 
-      *   [
 
-      *       'value1' => ['disabled' => true],
 
-      *       'value2' => ['label' => 'value 2'],
 
-      *   ];
 
-      *   ```
 
-      *
 
-      * - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options',
 
-      *   except that the array keys represent the optgroup labels specified in $items.
 
-      * - encodeSpaces: bool, whether to encode spaces in option prompt and option value with ` ` character.
 
-      *   Defaults to false.
 
-      * - encode: bool, whether to encode option prompt and option value characters.
 
-      *   Defaults to `true`. This option is available since 2.0.3.
 
-      *
 
-      * The rest of the options will be rendered as the attributes of the resulting tag. The values will
 
-      * be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated drop-down list tag
 
-      */
 
-     public static function activeDropDownList($model, $attribute, $items, $options = [])
 
-     {
 
-         if (empty($options['multiple'])) {
 
-             return static::activeListInput('dropDownList', $model, $attribute, $items, $options);
 
-         }
 
-         return static::activeListBox($model, $attribute, $items, $options);
 
-     }
 
-     /**
 
-      * Generates a list box.
 
-      * The selection of the list box is taken from the value of the model attribute.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $items the option data items. The array keys are option values, and the array values
 
-      * are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too).
 
-      * For each sub-array, an option group will be generated whose label is the key associated with the sub-array.
 
-      * If you have a list of data models, you may convert them into the format described above using
 
-      * [[\yii\helpers\ArrayHelper::map()]].
 
-      *
 
-      * Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in
 
-      * the labels will also be HTML-encoded.
 
-      * @param array $options the tag options in terms of name-value pairs. The following options are specially handled:
 
-      *
 
-      * - prompt: string, a prompt text to be displayed as the first option. Since version 2.0.11 you can use an array
 
-      *   to override the value and to set other tag attributes:
 
-      *
 
-      *   ```php
 
-      *   ['text' => 'Please select', 'options' => ['value' => 'none', 'class' => 'prompt', 'label' => 'Select']],
 
-      *   ```
 
-      *
 
-      * - options: array, the attributes for the select option tags. The array keys must be valid option values,
 
-      *   and the array values are the extra attributes for the corresponding option tags. For example,
 
-      *
 
-      *   ```php
 
-      *   [
 
-      *       'value1' => ['disabled' => true],
 
-      *       'value2' => ['label' => 'value 2'],
 
-      *   ];
 
-      *   ```
 
-      *
 
-      * - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options',
 
-      *   except that the array keys represent the optgroup labels specified in $items.
 
-      * - unselect: string, the value that will be submitted when no option is selected.
 
-      *   When this attribute is set, a hidden field will be generated so that if no option is selected in multiple
 
-      *   mode, we can still obtain the posted unselect value.
 
-      * - encodeSpaces: bool, whether to encode spaces in option prompt and option value with ` ` character.
 
-      *   Defaults to false.
 
-      * - encode: bool, whether to encode option prompt and option value characters.
 
-      *   Defaults to `true`. This option is available since 2.0.3.
 
-      *
 
-      * The rest of the options will be rendered as the attributes of the resulting tag. The values will
 
-      * be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated list box tag
 
-      */
 
-     public static function activeListBox($model, $attribute, $items, $options = [])
 
-     {
 
-         return static::activeListInput('listBox', $model, $attribute, $items, $options);
 
-     }
 
-     /**
 
-      * Generates a list of checkboxes.
 
-      * A checkbox list allows multiple selection, like [[listBox()]].
 
-      * As a result, the corresponding submitted value is an array.
 
-      * The selection of the checkbox list is taken from the value of the model attribute.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $items the data item used to generate the checkboxes.
 
-      * The array keys are the checkbox values, and the array values are the corresponding labels.
 
-      * Note that the labels will NOT be HTML-encoded, while the values will.
 
-      * @param array $options options (name => config) for the checkbox list container tag.
 
-      * The following options are specially handled:
 
-      *
 
-      * - tag: string|false, the tag name of the container element. False to render checkbox without container.
 
-      *   See also [[tag()]].
 
-      * - unselect: string, the value that should be submitted when none of the checkboxes is selected.
 
-      *   You may set this option to be null to prevent default value submission.
 
-      *   If this option is not set, an empty string will be submitted.
 
-      * - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to true.
 
-      *   This option is ignored if `item` option is set.
 
-      * - separator: string, the HTML code that separates items.
 
-      * - itemOptions: array, the options for generating the checkbox tag using [[checkbox()]].
 
-      * - item: callable, a callback that can be used to customize the generation of the HTML code
 
-      *   corresponding to a single item in $items. The signature of this callback must be:
 
-      *
 
-      *   ```php
 
-      *   function ($index, $label, $name, $checked, $value)
 
-      *   ```
 
-      *
 
-      *   where $index is the zero-based index of the checkbox in the whole list; $label
 
-      *   is the label for the checkbox; and $name, $value and $checked represent the name,
 
-      *   value and the checked status of the checkbox input.
 
-      *
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated checkbox list
 
-      */
 
-     public static function activeCheckboxList($model, $attribute, $items, $options = [])
 
-     {
 
-         return static::activeListInput('checkboxList', $model, $attribute, $items, $options);
 
-     }
 
-     /**
 
-      * Generates a list of radio buttons.
 
-      * A radio button list is like a checkbox list, except that it only allows single selection.
 
-      * The selection of the radio buttons is taken from the value of the model attribute.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $items the data item used to generate the radio buttons.
 
-      * The array keys are the radio values, and the array values are the corresponding labels.
 
-      * Note that the labels will NOT be HTML-encoded, while the values will.
 
-      * @param array $options options (name => config) for the radio button list container tag.
 
-      * The following options are specially handled:
 
-      *
 
-      * - tag: string|false, the tag name of the container element. False to render radio button without container.
 
-      *   See also [[tag()]].
 
-      * - unselect: string, the value that should be submitted when none of the radio buttons is selected.
 
-      *   You may set this option to be null to prevent default value submission.
 
-      *   If this option is not set, an empty string will be submitted.
 
-      * - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to true.
 
-      *   This option is ignored if `item` option is set.
 
-      * - separator: string, the HTML code that separates items.
 
-      * - itemOptions: array, the options for generating the radio button tag using [[radio()]].
 
-      * - item: callable, a callback that can be used to customize the generation of the HTML code
 
-      *   corresponding to a single item in $items. The signature of this callback must be:
 
-      *
 
-      *   ```php
 
-      *   function ($index, $label, $name, $checked, $value)
 
-      *   ```
 
-      *
 
-      *   where $index is the zero-based index of the radio button in the whole list; $label
 
-      *   is the label for the radio button; and $name, $value and $checked represent the name,
 
-      *   value and the checked status of the radio button input.
 
-      *
 
-      * See [[renderTagAttributes()]] for details on how attributes are being rendered.
 
-      *
 
-      * @return string the generated radio button list
 
-      */
 
-     public static function activeRadioList($model, $attribute, $items, $options = [])
 
-     {
 
-         return static::activeListInput('radioList', $model, $attribute, $items, $options);
 
-     }
 
-     /**
 
-      * Generates a list of input fields.
 
-      * This method is mainly called by [[activeListBox()]], [[activeRadioList()]] and [[activeCheckboxList()]].
 
-      * @param string $type the input type. This can be 'listBox', 'radioList', or 'checkBoxList'.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
 
-      * about attribute expression.
 
-      * @param array $items the data item used to generate the input fields.
 
-      * The array keys are the input values, and the array values are the corresponding labels.
 
-      * Note that the labels will NOT be HTML-encoded, while the values will.
 
-      * @param array $options options (name => config) for the input list. The supported special options
 
-      * depend on the input type specified by `$type`.
 
-      * @return string the generated input list
 
-      */
 
-     protected static function activeListInput($type, $model, $attribute, $items, $options = [])
 
-     {
 
-         $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);
 
-         $selection = isset($options['value']) ? $options['value'] : static::getAttributeValue($model, $attribute);
 
-         if (!array_key_exists('unselect', $options)) {
 
-             $options['unselect'] = '';
 
-         }
 
-         if (!array_key_exists('id', $options)) {
 
-             $options['id'] = static::getInputId($model, $attribute);
 
-         }
 
-         return static::$type($name, $selection, $items, $options);
 
-     }
 
-     /**
 
-      * Renders the option tags that can be used by [[dropDownList()]] and [[listBox()]].
 
-      * @param string|array|null $selection the selected value(s). String for single or array for multiple selection(s).
 
-      * @param array $items the option data items. The array keys are option values, and the array values
 
-      * are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too).
 
-      * For each sub-array, an option group will be generated whose label is the key associated with the sub-array.
 
-      * If you have a list of data models, you may convert them into the format described above using
 
-      * [[\yii\helpers\ArrayHelper::map()]].
 
-      *
 
-      * Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in
 
-      * the labels will also be HTML-encoded.
 
-      * @param array $tagOptions the $options parameter that is passed to the [[dropDownList()]] or [[listBox()]] call.
 
-      * This method will take out these elements, if any: "prompt", "options" and "groups". See more details
 
-      * in [[dropDownList()]] for the explanation of these elements.
 
-      *
 
-      * @return string the generated list options
 
-      */
 
-     public static function renderSelectOptions($selection, $items, &$tagOptions = [])
 
-     {
 
-         if (ArrayHelper::isTraversable($selection)) {
 
-             $selection = array_map('strval', (array)$selection);
 
-         }
 
-         $lines = [];
 
-         $encodeSpaces = ArrayHelper::remove($tagOptions, 'encodeSpaces', false);
 
-         $encode = ArrayHelper::remove($tagOptions, 'encode', true);
 
-         if (isset($tagOptions['prompt'])) {
 
-             $promptOptions = ['value' => ''];
 
-             if (is_string($tagOptions['prompt'])) {
 
-                 $promptText = $tagOptions['prompt'];
 
-             } else {
 
-                 $promptText = $tagOptions['prompt']['text'];
 
-                 $promptOptions = array_merge($promptOptions, $tagOptions['prompt']['options']);
 
-             }
 
-             $promptText = $encode ? static::encode($promptText) : $promptText;
 
-             if ($encodeSpaces) {
 
-                 $promptText = str_replace(' ', ' ', $promptText);
 
-             }
 
-             $lines[] = static::tag('option', $promptText, $promptOptions);
 
-         }
 
-         $options = isset($tagOptions['options']) ? $tagOptions['options'] : [];
 
-         $groups = isset($tagOptions['groups']) ? $tagOptions['groups'] : [];
 
-         unset($tagOptions['prompt'], $tagOptions['options'], $tagOptions['groups']);
 
-         $options['encodeSpaces'] = ArrayHelper::getValue($options, 'encodeSpaces', $encodeSpaces);
 
-         $options['encode'] = ArrayHelper::getValue($options, 'encode', $encode);
 
-         foreach ($items as $key => $value) {
 
-             if (is_array($value)) {
 
-                 $groupAttrs = isset($groups[$key]) ? $groups[$key] : [];
 
-                 if (!isset($groupAttrs['label'])) {
 
-                     $groupAttrs['label'] = $key;
 
-                 }
 
-                 $attrs = ['options' => $options, 'groups' => $groups, 'encodeSpaces' => $encodeSpaces, 'encode' => $encode];
 
-                 $content = static::renderSelectOptions($selection, $value, $attrs);
 
-                 $lines[] = static::tag('optgroup', "\n" . $content . "\n", $groupAttrs);
 
-             } else {
 
-                 $attrs = isset($options[$key]) ? $options[$key] : [];
 
-                 $attrs['value'] = (string) $key;
 
-                 if (!array_key_exists('selected', $attrs)) {
 
-                     $attrs['selected'] = $selection !== null &&
 
-                         (!ArrayHelper::isTraversable($selection) && !strcmp($key, $selection)
 
-                         || ArrayHelper::isTraversable($selection) && ArrayHelper::isIn((string)$key, $selection));
 
-                 }
 
-                 $text = $encode ? static::encode($value) : $value;
 
-                 if ($encodeSpaces) {
 
-                     $text = str_replace(' ', ' ', $text);
 
-                 }
 
-                 $lines[] = static::tag('option', $text, $attrs);
 
-             }
 
-         }
 
-         return implode("\n", $lines);
 
-     }
 
-     /**
 
-      * Renders the HTML tag attributes.
 
-      *
 
-      * Attributes whose values are of boolean type will be treated as
 
-      * [boolean attributes](http://www.w3.org/TR/html5/infrastructure.html#boolean-attributes).
 
-      *
 
-      * Attributes whose values are null will not be rendered.
 
-      *
 
-      * The values of attributes will be HTML-encoded using [[encode()]].
 
-      *
 
-      * The "data" attribute is specially handled when it is receiving an array value. In this case,
 
-      * the array will be "expanded" and a list data attributes will be rendered. For example,
 
-      * if `'data' => ['id' => 1, 'name' => 'yii']`, then this will be rendered:
 
-      * `data-id="1" data-name="yii"`.
 
-      * Additionally `'data' => ['params' => ['id' => 1, 'name' => 'yii'], 'status' => 'ok']` will be rendered as:
 
-      * `data-params='{"id":1,"name":"yii"}' data-status="ok"`.
 
-      *
 
-      * @param array $attributes attributes to be rendered. The attribute values will be HTML-encoded using [[encode()]].
 
-      * @return string the rendering result. If the attributes are not empty, they will be rendered
 
-      * into a string with a leading white space (so that it can be directly appended to the tag name
 
-      * in a tag. If there is no attribute, an empty string will be returned.
 
-      * @see addCssClass()
 
-      */
 
-     public static function renderTagAttributes($attributes)
 
-     {
 
-         if (count($attributes) > 1) {
 
-             $sorted = [];
 
-             foreach (static::$attributeOrder as $name) {
 
-                 if (isset($attributes[$name])) {
 
-                     $sorted[$name] = $attributes[$name];
 
-                 }
 
-             }
 
-             $attributes = array_merge($sorted, $attributes);
 
-         }
 
-         $html = '';
 
-         foreach ($attributes as $name => $value) {
 
-             if (is_bool($value)) {
 
-                 if ($value) {
 
-                     $html .= " $name";
 
-                 }
 
-             } elseif (is_array($value)) {
 
-                 if (in_array($name, static::$dataAttributes)) {
 
-                     foreach ($value as $n => $v) {
 
-                         if (is_array($v)) {
 
-                             $html .= " $name-$n='" . Json::htmlEncode($v) . "'";
 
-                         } else {
 
-                             $html .= " $name-$n=\"" . static::encode($v) . '"';
 
-                         }
 
-                     }
 
-                 } elseif ($name === 'class') {
 
-                     if (empty($value)) {
 
-                         continue;
 
-                     }
 
-                     $html .= " $name=\"" . static::encode(implode(' ', $value)) . '"';
 
-                 } elseif ($name === 'style') {
 
-                     if (empty($value)) {
 
-                         continue;
 
-                     }
 
-                     $html .= " $name=\"" . static::encode(static::cssStyleFromArray($value)) . '"';
 
-                 } else {
 
-                     $html .= " $name='" . Json::htmlEncode($value) . "'";
 
-                 }
 
-             } elseif ($value !== null) {
 
-                 $html .= " $name=\"" . static::encode($value) . '"';
 
-             }
 
-         }
 
-         return $html;
 
-     }
 
-     /**
 
-      * Adds a CSS class (or several classes) to the specified options.
 
-      *
 
-      * If the CSS class is already in the options, it will not be added again.
 
-      * If class specification at given options is an array, and some class placed there with the named (string) key,
 
-      * overriding of such key will have no effect. For example:
 
-      *
 
-      * ```php
 
-      * $options = ['class' => ['persistent' => 'initial']];
 
-      * Html::addCssClass($options, ['persistent' => 'override']);
 
-      * var_dump($options['class']); // outputs: array('persistent' => 'initial');
 
-      * ```
 
-      *
 
-      * @param array $options the options to be modified.
 
-      * @param string|array $class the CSS class(es) to be added
 
-      * @see mergeCssClasses()
 
-      * @see removeCssClass()
 
-      */
 
-     public static function addCssClass(&$options, $class)
 
-     {
 
-         if (isset($options['class'])) {
 
-             if (is_array($options['class'])) {
 
-                 $options['class'] = self::mergeCssClasses($options['class'], (array) $class);
 
-             } else {
 
-                 $classes = preg_split('/\s+/', $options['class'], -1, PREG_SPLIT_NO_EMPTY);
 
-                 $options['class'] = implode(' ', self::mergeCssClasses($classes, (array) $class));
 
-             }
 
-         } else {
 
-             $options['class'] = $class;
 
-         }
 
-     }
 
-     /**
 
-      * Merges already existing CSS classes with new one.
 
-      * This method provides the priority for named existing classes over additional.
 
-      * @param array $existingClasses already existing CSS classes.
 
-      * @param array $additionalClasses CSS classes to be added.
 
-      * @return array merge result.
 
-      * @see addCssClass()
 
-      */
 
-     private static function mergeCssClasses(array $existingClasses, array $additionalClasses)
 
-     {
 
-         foreach ($additionalClasses as $key => $class) {
 
-             if (is_int($key) && !in_array($class, $existingClasses)) {
 
-                 $existingClasses[] = $class;
 
-             } elseif (!isset($existingClasses[$key])) {
 
-                 $existingClasses[$key] = $class;
 
-             }
 
-         }
 
-         return array_unique($existingClasses);
 
-     }
 
-     /**
 
-      * Removes a CSS class from the specified options.
 
-      * @param array $options the options to be modified.
 
-      * @param string|array $class the CSS class(es) to be removed
 
-      * @see addCssClass()
 
-      */
 
-     public static function removeCssClass(&$options, $class)
 
-     {
 
-         if (isset($options['class'])) {
 
-             if (is_array($options['class'])) {
 
-                 $classes = array_diff($options['class'], (array) $class);
 
-                 if (empty($classes)) {
 
-                     unset($options['class']);
 
-                 } else {
 
-                     $options['class'] = $classes;
 
-                 }
 
-             } else {
 
-                 $classes = preg_split('/\s+/', $options['class'], -1, PREG_SPLIT_NO_EMPTY);
 
-                 $classes = array_diff($classes, (array) $class);
 
-                 if (empty($classes)) {
 
-                     unset($options['class']);
 
-                 } else {
 
-                     $options['class'] = implode(' ', $classes);
 
-                 }
 
-             }
 
-         }
 
-     }
 
-     /**
 
-      * Adds the specified CSS style to the HTML options.
 
-      *
 
-      * If the options already contain a `style` element, the new style will be merged
 
-      * with the existing one. If a CSS property exists in both the new and the old styles,
 
-      * the old one may be overwritten if `$overwrite` is true.
 
-      *
 
-      * For example,
 
-      *
 
-      * ```php
 
-      * Html::addCssStyle($options, 'width: 100px; height: 200px');
 
-      * ```
 
-      *
 
-      * @param array $options the HTML options to be modified.
 
-      * @param string|array $style the new style string (e.g. `'width: 100px; height: 200px'`) or
 
-      * array (e.g. `['width' => '100px', 'height' => '200px']`).
 
-      * @param bool $overwrite whether to overwrite existing CSS properties if the new style
 
-      * contain them too.
 
-      * @see removeCssStyle()
 
-      * @see cssStyleFromArray()
 
-      * @see cssStyleToArray()
 
-      */
 
-     public static function addCssStyle(&$options, $style, $overwrite = true)
 
-     {
 
-         if (!empty($options['style'])) {
 
-             $oldStyle = is_array($options['style']) ? $options['style'] : static::cssStyleToArray($options['style']);
 
-             $newStyle = is_array($style) ? $style : static::cssStyleToArray($style);
 
-             if (!$overwrite) {
 
-                 foreach ($newStyle as $property => $value) {
 
-                     if (isset($oldStyle[$property])) {
 
-                         unset($newStyle[$property]);
 
-                     }
 
-                 }
 
-             }
 
-             $style = array_merge($oldStyle, $newStyle);
 
-         }
 
-         $options['style'] = is_array($style) ? static::cssStyleFromArray($style) : $style;
 
-     }
 
-     /**
 
-      * Removes the specified CSS style from the HTML options.
 
-      *
 
-      * For example,
 
-      *
 
-      * ```php
 
-      * Html::removeCssStyle($options, ['width', 'height']);
 
-      * ```
 
-      *
 
-      * @param array $options the HTML options to be modified.
 
-      * @param string|array $properties the CSS properties to be removed. You may use a string
 
-      * if you are removing a single property.
 
-      * @see addCssStyle()
 
-      */
 
-     public static function removeCssStyle(&$options, $properties)
 
-     {
 
-         if (!empty($options['style'])) {
 
-             $style = is_array($options['style']) ? $options['style'] : static::cssStyleToArray($options['style']);
 
-             foreach ((array) $properties as $property) {
 
-                 unset($style[$property]);
 
-             }
 
-             $options['style'] = static::cssStyleFromArray($style);
 
-         }
 
-     }
 
-     /**
 
-      * Converts a CSS style array into a string representation.
 
-      *
 
-      * For example,
 
-      *
 
-      * ```php
 
-      * print_r(Html::cssStyleFromArray(['width' => '100px', 'height' => '200px']));
 
-      * // will display: 'width: 100px; height: 200px;'
 
-      * ```
 
-      *
 
-      * @param array $style the CSS style array. The array keys are the CSS property names,
 
-      * and the array values are the corresponding CSS property values.
 
-      * @return string the CSS style string. If the CSS style is empty, a null will be returned.
 
-      */
 
-     public static function cssStyleFromArray(array $style)
 
-     {
 
-         $result = '';
 
-         foreach ($style as $name => $value) {
 
-             $result .= "$name: $value; ";
 
-         }
 
-         // return null if empty to avoid rendering the "style" attribute
 
-         return $result === '' ? null : rtrim($result);
 
-     }
 
-     /**
 
-      * Converts a CSS style string into an array representation.
 
-      *
 
-      * The array keys are the CSS property names, and the array values
 
-      * are the corresponding CSS property values.
 
-      *
 
-      * For example,
 
-      *
 
-      * ```php
 
-      * print_r(Html::cssStyleToArray('width: 100px; height: 200px;'));
 
-      * // will display: ['width' => '100px', 'height' => '200px']
 
-      * ```
 
-      *
 
-      * @param string $style the CSS style string
 
-      * @return array the array representation of the CSS style
 
-      */
 
-     public static function cssStyleToArray($style)
 
-     {
 
-         $result = [];
 
-         foreach (explode(';', $style) as $property) {
 
-             $property = explode(':', $property);
 
-             if (count($property) > 1) {
 
-                 $result[trim($property[0])] = trim($property[1]);
 
-             }
 
-         }
 
-         return $result;
 
-     }
 
-     /**
 
-      * Returns the real attribute name from the given attribute expression.
 
-      *
 
-      * An attribute expression is an attribute name prefixed and/or suffixed with array indexes.
 
-      * It is mainly used in tabular data input and/or input of array type. Below are some examples:
 
-      *
 
-      * - `[0]content` is used in tabular data input to represent the "content" attribute
 
-      *   for the first model in tabular input;
 
-      * - `dates[0]` represents the first array element of the "dates" attribute;
 
-      * - `[0]dates[0]` represents the first array element of the "dates" attribute
 
-      *   for the first model in tabular input.
 
-      *
 
-      * If `$attribute` has neither prefix nor suffix, it will be returned back without change.
 
-      * @param string $attribute the attribute name or expression
 
-      * @return string the attribute name without prefix and suffix.
 
-      * @throws InvalidArgumentException if the attribute name contains non-word characters.
 
-      */
 
-     public static function getAttributeName($attribute)
 
-     {
 
-         if (preg_match(static::$attributeRegex, $attribute, $matches)) {
 
-             return $matches[2];
 
-         }
 
-         throw new InvalidArgumentException('Attribute name must contain word characters only.');
 
-     }
 
-     /**
 
-      * Returns the value of the specified attribute name or expression.
 
-      *
 
-      * For an attribute expression like `[0]dates[0]`, this method will return the value of `$model->dates[0]`.
 
-      * See [[getAttributeName()]] for more details about attribute expression.
 
-      *
 
-      * If an attribute value is an instance of [[ActiveRecordInterface]] or an array of such instances,
 
-      * the primary value(s) of the AR instance(s) will be returned instead.
 
-      *
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression
 
-      * @return string|array the corresponding attribute value
 
-      * @throws InvalidArgumentException if the attribute name contains non-word characters.
 
-      */
 
-     public static function getAttributeValue($model, $attribute)
 
-     {
 
-         if (!preg_match(static::$attributeRegex, $attribute, $matches)) {
 
-             throw new InvalidArgumentException('Attribute name must contain word characters only.');
 
-         }
 
-         $attribute = $matches[2];
 
-         $value = $model->$attribute;
 
-         if ($matches[3] !== '') {
 
-             foreach (explode('][', trim($matches[3], '[]')) as $id) {
 
-                 if ((is_array($value) || $value instanceof \ArrayAccess) && isset($value[$id])) {
 
-                     $value = $value[$id];
 
-                 } else {
 
-                     return null;
 
-                 }
 
-             }
 
-         }
 
-         // https://github.com/yiisoft/yii2/issues/1457
 
-         if (is_array($value)) {
 
-             foreach ($value as $i => $v) {
 
-                 if ($v instanceof ActiveRecordInterface) {
 
-                     $v = $v->getPrimaryKey(false);
 
-                     $value[$i] = is_array($v) ? json_encode($v) : $v;
 
-                 }
 
-             }
 
-         } elseif ($value instanceof ActiveRecordInterface) {
 
-             $value = $value->getPrimaryKey(false);
 
-             return is_array($value) ? json_encode($value) : $value;
 
-         }
 
-         return $value;
 
-     }
 
-     /**
 
-      * Generates an appropriate input name for the specified attribute name or expression.
 
-      *
 
-      * This method generates a name that can be used as the input name to collect user input
 
-      * for the specified attribute. The name is generated according to the [[Model::formName|form name]]
 
-      * of the model and the given attribute name. For example, if the form name of the `Post` model
 
-      * is `Post`, then the input name generated for the `content` attribute would be `Post[content]`.
 
-      *
 
-      * See [[getAttributeName()]] for explanation of attribute expression.
 
-      *
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression
 
-      * @return string the generated input name
 
-      * @throws InvalidArgumentException if the attribute name contains non-word characters.
 
-      */
 
-     public static function getInputName($model, $attribute)
 
-     {
 
-         $formName = $model->formName();
 
-         if (!preg_match(static::$attributeRegex, $attribute, $matches)) {
 
-             throw new InvalidArgumentException('Attribute name must contain word characters only.');
 
-         }
 
-         $prefix = $matches[1];
 
-         $attribute = $matches[2];
 
-         $suffix = $matches[3];
 
-         if ($formName === '' && $prefix === '') {
 
-             return $attribute . $suffix;
 
-         } elseif ($formName !== '') {
 
-             return $formName . $prefix . "[$attribute]" . $suffix;
 
-         }
 
-         throw new InvalidArgumentException(get_class($model) . '::formName() cannot be empty for tabular inputs.');
 
-     }
 
-     /**
 
-      * Generates an appropriate input ID for the specified attribute name or expression.
 
-      *
 
-      * This method converts the result [[getInputName()]] into a valid input ID.
 
-      * For example, if [[getInputName()]] returns `Post[content]`, this method will return `post-content`.
 
-      * @param Model $model the model object
 
-      * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for explanation of attribute expression.
 
-      * @return string the generated input ID
 
-      * @throws InvalidArgumentException if the attribute name contains non-word characters.
 
-      */
 
-     public static function getInputId($model, $attribute)
 
-     {
 
-         $charset = Yii::$app ? Yii::$app->charset : 'UTF-8';
 
-         $name = mb_strtolower(static::getInputName($model, $attribute), $charset);
 
-         return str_replace(['[]', '][', '[', ']', ' ', '.'], ['', '-', '-', '', '-', '-'], $name);
 
-     }
 
-     /**
 
-      * Escapes regular expression to use in JavaScript.
 
-      * @param string $regexp the regular expression to be escaped.
 
-      * @return string the escaped result.
 
-      * @since 2.0.6
 
-      */
 
-     public static function escapeJsRegularExpression($regexp)
 
-     {
 
-         $pattern = preg_replace('/\\\\x\{?([0-9a-fA-F]+)\}?/', '\u$1', $regexp);
 
-         $deliminator = substr($pattern, 0, 1);
 
-         $pos = strrpos($pattern, $deliminator, 1);
 
-         $flag = substr($pattern, $pos + 1);
 
-         if ($deliminator !== '/') {
 
-             $pattern = '/' . str_replace('/', '\\/', substr($pattern, 1, $pos - 1)) . '/';
 
-         } else {
 
-             $pattern = substr($pattern, 0, $pos + 1);
 
-         }
 
-         if (!empty($flag)) {
 
-             $pattern .= preg_replace('/[^igmu]/', '', $flag);
 
-         }
 
-         return $pattern;
 
-     }
 
- }
 
 
  |