';
}
/**
* @param $model
* @param $attribute
* @return string
* 获取要填入属性的输入框name
*/
private 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.');
}
/**
* @param $model
* @param $attribute
* @return mixed
* 获取要填入属性的输入框id
*/
private 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);
}
}