Final Class Yiisoft\Yii\DataView\GridView\Column\RadioColumnRenderer
| Inheritance | Yiisoft\Yii\DataView\GridView\Column\RadioColumnRenderer |
|---|---|
| Implements | Yiisoft\Yii\DataView\GridView\Column\ColumnRendererInterface |
RadioColumnRenderer handles the rendering of radio button columns in a grid.
Public Methods
Method Details
public function renderBody(ColumnInterface $column, Cell $cell, DataContext $context): Cell
{
$inputAttributes = $column->inputAttributes;
$name = null;
$value = null;
if (!array_key_exists('name', $inputAttributes)) {
$name = 'radio-selection';
}
if (!array_key_exists('value', $inputAttributes)) {
$value = $context->key;
}
$input = Html::radio($name, $value, $inputAttributes);
$contentClosure = $column->content;
/** @var string|Stringable $content */
$content = $contentClosure === null ? $input : $contentClosure($input, $context);
return $cell
->addAttributes($column->bodyAttributes)
->content($content)
->encode(false);
}
public function renderColumn(ColumnInterface $column, Cell $cell, GlobalContext $context): Cell
{
return $cell->addAttributes($column->columnAttributes);
}
public function renderHeader(ColumnInterface $column, Cell $cell, GlobalContext $context): ?Cell
{
$header = $column->header;
if ($header === null) {
return null;
}
return $cell
->addAttributes($column->headerAttributes)
->content($header);
}
Signup or Login in order to comment.