Skip to content

Instantly share code, notes, and snippets.

@melaniecarr23
Created September 9, 2016 03:15
Show Gist options
  • Select an option

  • Save melaniecarr23/39a457b862065c78aaf7ded840a3bbcd to your computer and use it in GitHub Desktop.

Select an option

Save melaniecarr23/39a457b862065c78aaf7ded840a3bbcd to your computer and use it in GitHub Desktop.
PHP: Yii2 kartik editable patientID
// patient dropdown editable column
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'patientID',
'pageSummary' => true,
'width' => '100px',
// filtering grid
'filterType'=>GridView::FILTER_SELECT2,
'filter'=>ArrayHelper::map(Patient::find()->where(['active_patient'=>1])->orderBy('Nickname')->asArray()->all(), 'ID', 'Nickname'),
'filterWidgetOptions'=>[
'pluginOptions'=>['allowClear'=>true],
],
'filterInputOptions'=>['placeholder'=>'- Patient -'],
// end filtering grid
'editableOptions'=> function ($model, $key, $index, $widget) {
$patients = ArrayHelper::map(Patient::find()->where(['active_patient'=>1])->orderBy('Nickname')->asArray()->all(),'ID','Nickname');
return [
'header' => 'Patient',
'attribute' => 'patientID',
'size' => 'sm',
'inputType' => 'dropDownList',
'displayValueConfig' => $patients,
'data' => $patients
];
}
],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment