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 | * ```php |
||
55 | * 'radioOptions' => function ($model, $key, $index, $column) { |
||
56 | * return ['value' => $model->attribute]; |
||
57 | * } |
||
58 | * ``` |
||
59 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
60 | */ |
||
61 | public $radioOptions = []; |
||
62 | |||
63 | |||
64 | /** |
||
65 | * @inheritdoc |
||
66 | * @throws \yii\base\InvalidConfigException if [[name]] is not set. |
||
67 | */ |
||
68 | 4 | public function init() |
|
75 | |||
76 | /** |
||
77 | * @inheritdoc |
||
78 | */ |
||
79 | 3 | protected function renderDataCellContent($model, $key, $index) |
|
92 | } |
||
93 |