Hello,
I’m now programming with yii since a week and could solve almost all my problems here except one. I have a TabularForm where I have a delete button in to delete an attribute entry. The standard implementation here only removes the row from the gui, but not from the db. So I want to implement this by myself, but I cant figure out from where I get the id’s I need to do this. The callback gives me only the key (row id from the table).
here the code form the table:
echo TabularForm::widget([
'dataProvider' => $dataProvider,
'formName' => 'PersonsAssociationsMap',
'checkboxColumn' => false,
'actionColumn' => false,
'id' => 'tablePersonsAssociationsMap',
'attributeDefaults' => [
'type' => TabularForm::INPUT_TEXT,
],
'attributes' => [
'id_persons' => [
'label' => 'persons',
'type' => TabularForm::INPUT_WIDGET,
'widgetClass' => \kartik\widgets\Select2::className(),
'options' => [
'data' => \yii\helpers\ArrayHelper::map(\app\models\Persons::find()->orderBy('id')->asArray()->all(), 'id',
function($model, $defaultValue) {
return $model['lastname'].' '.$model['firstname'];
}),
'options' => ['placeholder' => Yii::t('app', 'Choose Persons')],
],
'columnOptions' => ['width' => '200px']
],
'del' => [
'type' => 'raw',
'label' => '',
'value' => function($model, $key) {
return Html::a('<i class="glyphicon glyphicon-trash"></i>', '#', ['title' => Yii::t('app', 'Delete'),
'onClick' => 'delPersonsMap("'.$key.'","baseid","personid","Associations"); return false;',
'id' => 'tb-persons-associations-map-del-btn']);
},
],
],
'gridSettings' => [
'panel' => [
'heading' => false,
'type' => GridView::TYPE_DEFAULT,
'before' => false,
'footer' => false,
'after' => Html::button('<i class="glyphicon glyphicon-plus"></i>' . Yii::t('app', 'Add Associations Persons Map'),
['value' => Url::to('../persons/chooser?baseid='.$baseID.'&filter=&openerClassName=PersonsAssociationsMap&basename='.urlencode($baseName)), 'class' => 'btn btn-success kv-batch-create', 'id' => 'modalAddPersons'])
//Html::button('<i class="glyphicon glyphicon-plus"></i>' . Yii::t('app', 'Add Persons Associations Map'), ['type' => 'button', 'class' => 'btn btn-success kv-batch-create', 'onClick' => 'addRowTbPersonsAssociationsMap()']),
]
]
]);
so perhaps somebody can help me here a little bit
with regards
Georg