I have a form that is used to create customers order. Customer are pulled from the database.
Want am trying to achieve is to have a link or button at the end of the dropdownlist used to create new customers. This form should be a modal.
After submitting the form, the newly created customer should be selected on the dropdown list.
I have the modal working but the modal button is outside the dropdownlist…i want it inside
My deopdownlist
`field($model, ‘ser_own_id’, [‘labelOptions’=>[‘class’=>‘labelchange’]])->widget(Select2::classname(),[‘data’=> [‘newclient’ => ‘Add New’] + ArrayHelper::map(Owner::find()->all(),‘owner_id’,‘reg_no’),‘language’=>‘en’, ‘options’=>[‘placeholder’=>‘Select Registration Number’, ‘id’=>‘zipCode’], ‘pluginOptions’=>[ ‘allowClear’=>true ], ]); ?>
Url::to(‘index.php?r=owner/new’), ‘class’ => ‘btn btn-success’, ‘id’ => ‘modalButton’]);?> `
Modal form
`<?php
Modal::begin([
‘header’ =>’
Vehicle owner
',
‘id’ => ‘modal’,
‘size’ => ‘modal-sm’,
]);
echo "<div id='modalContent'></div>";
Modal::end();
?>`
Action used by modal to create new customers
`public function actionNew()
{
$model = new Owner();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
//return $this->redirect(['view', 'id' => $model->owner_id]);
echo 1;
}
else{
return $this->renderAjax('new', [
'model' => $model,
]);
}
}`