Dears,
How can I use a dual list box so that when I click save button, the items selected will be entered to the database. I read it is saved in JSON format but how could I do that?
Thanks in advance!
Dears,
How can I use a dual list box so that when I click save button, the items selected will be entered to the database. I read it is saved in JSON format but how could I do that?
Thanks in advance!
I have the same type of issue ( I don’t need JSON ).
I have two standard list boxes, as opposed to katrik\sortable and maksyutin\duallistbox. I couldn’t find good help on these.
One List box is "Assigned IDs". One List box is "Unassigned IDs". I need to "delete" an entry / model when the "unassign" button is pushed. I need to "insert" an entry / model when the "assign" button is pushed. I believe I am loading the boxes correctly in my actionIndex function.
I have 3 forms (not sure if it’s right). 1: contactid for searching (works). 2: contactid/contactruleid (for deleting). 2: contactid/contactruleid (for inserting). Deletion fails with “missing required parameters”. Any ideas?
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]);
echo $form->field($searchModel, 'contactid')->dropDownList(
ArrayHelper::map(User::find()->select('id, username')->all(), 'id', 'username')
,['prompt' => 'SELECT USER',
'onchange' => 'this.form.submit()'
]);
ActiveForm::end(); ?>
// Needs to delete the entered model
<?php $form2 = ActiveForm::begin([
'id' => 'form2',
'action' => ['delete'],
'method' => 'post',
]);
echo $form2->field($searchModel, 'contactid')->textInput();
echo $form2->field($searchModel, 'contactruleid' )->listBox(
$assignedIds
,[ 'multiple' => false,
'disabled' => false,
'size' => 10,
'style' => 'width:200px'
])->label('Assigned');
echo Html::submitButton('unassign', ['class' => 'btn btn-primary']);
ActiveForm::end();
?>
// Needs to insert/update
$form3 = ActiveForm::begin([
'action' => ['create'],
'method' => 'post',
]);
$form3 fields.....
echo Html::submitButton('assign', ['class' => 'btn btn-primary']);
ActiveForm::end();
Delete Controller: I tried to do model->load(Yii::$app->request->post()) here too, but the contactid/contactruleid are always absent.
public function actionDelete($contactid, $contactruleid)
{
$this->findModel($contactid, $contactruleid)->delete();
return $this->redirect(['index']);
}
When I press ‘Unassign’ I always get, missing required parameters: contactid, contactruleid …