Skip to content

Instantly share code, notes, and snippets.

@melaniecarr23
Created September 9, 2016 03:02
Show Gist options
  • Save melaniecarr23/c698af5bc12d24e8d684d22365bbde38 to your computer and use it in GitHub Desktop.
Save melaniecarr23/c698af5bc12d24e8d684d22365bbde38 to your computer and use it in GitHub Desktop.
PHP: Yii2 Kartik editable dropdown w/filtering
// appt type dropdown editable column
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'appt_typeID',
'pageSummary' => true,
'width' => '100px',
// filtering grid
'filterType'=>GridView::FILTER_SELECT2,
'filter'=>ArrayHelper::map(ApptType::find()->orderBy('ID')->asArray()->all(),'ID', 'appt_abbr'),
'filterWidgetOptions'=>[
'pluginOptions'=>['allowClear'=>true],
],
'filterInputOptions'=>['placeholder'=>'- Type -'],
// end filtering grid
'editableOptions'=> function ($model, $key, $index, $widget) {
$appttypes = ArrayHelper::map(ApptType::find()->orderBy('ID')->asArray()->all(),'ID','appt_abbr');
return [
'header' => 'Appt Type',
'attribute' => 'appt_typeID',
'size' => 'sm',
'inputType' => Editable::INPUT_DROPDOWN_LIST,
'displayValueConfig' => $appttypes,
'data' => $appttypes,
//'formOptions'=> ['action' => ['/appt/editappt']] // point to new action
];
}
],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment