1 | <?php |
||
37 | class RadioButtonColumn extends Column |
||
38 | { |
||
39 | /** |
||
40 | * @var string the name of the input radio button input fields. |
||
41 | */ |
||
42 | public $name = 'radioButtonSelection'; |
||
43 | /** |
||
44 | * @var array|\Closure the HTML attributes for the radio buttons. This can either be an array of |
||
45 | * attributes or an anonymous function ([[Closure]]) returning such an array. |
||
46 | * |
||
47 | * The signature of the function should be as follows: `function ($model, $key, $index, $column)` |
||
48 | * where `$model`, `$key`, and `$index` refer to the model, key and index of the row currently being rendered |
||
49 | * and `$column` is a reference to the [[RadioButtonColumn]] object. |
||
50 | * |
||
51 | * A function may be used to assign different attributes to different rows based on the data in that row. |
||
52 | * Specifically if you want to set a different value for the radio button you can use this option |
||
53 | * in the following way (in this example using the `name` attribute of the model): |
||
54 | * |
||
55 | * ```php |
||
56 | * 'radioOptions' => function ($model, $key, $index, $column) { |
||
57 | * return ['value' => $model->attribute]; |
||
58 | * } |
||
59 | * ``` |
||
60 | * |
||
61 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
62 | */ |
||
63 | public $radioOptions = []; |
||
64 | |||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | * @throws \yii\base\InvalidConfigException if [[name]] is not set. |
||
69 | */ |
||
70 | 5 | public function init() |
|
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | 4 | protected function renderDataCellContent($model, $key, $index) |
|
98 | } |
||
99 |