framework/helpers/BaseHtml.php
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.');
    }
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 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.