static public formatAttribute ( $key, $value ) : string | ||
$key | The name of the attribute to create | |
$value | The value of the attribute to create. | |
Результат | string | The composed attribute. |
static function formatAttribute($key, $value)
{
if (is_array($value)) {
$value = implode(' ', $value);
}
return sprintf('%1$s="%2$s"', $key, Html::cleanInputText($value));
}
/** * Returns a space-delimited string with items of the $options array. * * @since version 0.85 * * @param $options Array of options. * * @return string Composed attributes. **/ static function parseAttributes($options = array()) { if (!is_string($options)) { $attributes = array(); foreach ($options as $key => $value) { $attributes[] = Html::formatAttribute($key, $value); } $out = implode(' ', $attributes); } else { $out = $options; } return $out; }