Modal form dont save

hello, everybody, assuming I’m a new guy.
I have a problem with a modal form, inside of a customer insertion form I want to make out the modal form that represents the personal data of the banks
so I used this code

<?php
            Modal::begin([
                'toggleButton' => [
                    'label' => '<i class="glyphicon glyphicon-plus"></i> Add',
                    'class' => 'btn btn-success'
                ],
                'closeButton' => [
                  'label' => 'Close',
                  'class' => 'btn btn-danger btn-sm pull-right',
                ],
                'size' => 'modal-lg',
            ]);
            $myModel = new Bank();
            echo $this->render('/bank/create', ['model' => $myModel]);
            Modal::end();
        ?>

the form is shown correctly but if I click on save it doesn’t save the data.
What am I doing wrong? I’m looking for a tutorial on how to do it but nobody faces this problem.
Thanks

What URL it submits to?

HI samdark!

 <form id="w2" action="/index.php?r=paymentstype%2Fupdate&amp;id=2" method="post">
<input type="hidden" name="_csrf" value="3vn57kSSDeXr87mxq8gzL12U_nTapN1k0E-7Rach7LeOyrGCCNpaosaw-Prnp3FWCuaRE6_PpwmbCswBwHaA2w==">
    <div class="form-group field-bank-cd_bank required">
<label class="control-label" for="bank-cd_bank">Cd Bank</label>
<input type="text" id="bank-cd_bank" class="form-control" name="Bank[Cd_bank]" maxlength="50" aria-required="true">

<div class="help-block"></div>
</div>
    <div class="form-group field-bank-descrizione">
<label class="control-label" for="bank-descrizione">Descrizione</label>
<input type="text" id="bank-descrizione" class="form-control" name="Bank[Descrizione]" maxlength="50">

<div class="help-block"></div>
</div>
    <div class="form-group field-bank-contobancario">
<label class="control-label" for="bank-contobancario">Contobancario</label>
<input type="text" id="bank-contobancario" class="form-control" name="Bank[Contobancario]" maxlength="50">

<div class="help-block"></div>
</div>
    <div class="form-group">
        <button type="submit" class="btn btn-success">Save</button>    </div>

    </form>

I think the action is wrong " action="/index.php?r=paymentstype%2Fupdate&id=2"" should be " "/index.php?r=/bank/create"instead how do I force him?

hi i have put this code

<?php
$script = <<< JS
   var form =jQuery('#modal');
    form.on('beforeSubmit', function(e) {
    e.preventDefault();
    jQuery.ajax({
        url: form.attr('action'),
        type: form.attr('method'),
        data: new FormData(form[0]),
        mimeType: 'multipart/form-data',
        contentType: false,
        cache: false,
        processData: false,
        dataType: 'json',
        success: function (data) {
            alert('done');
        }
    });
     return false;
});
JS;
$this->registerJs($script);
?>

and this is the modal

<?php
    Modal::begin([
            'header'=>'<h4>Banche</h4>',
            'id' => 'modal',
            'size'=>'modal-lg', //classe bootstrap
        ]);
    echo "<div id='modalContent'></div>";
    Modal::end();
?>

and in the controller

public function actionCreateaj()

{
$model = new Bank();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
\Yii::$app->response->format = Response::FORMAT_JSON;
return 1 ;//[‘Cd_Bank’=>$Cd_Bank, ‘Descrizione’=>true];
} elseif (Yii::$app->request->isAjax)
{
return $this->renderAjax(‘create’, [‘model’ => $model]);
}
}

the result is a page with print 1
but i want that the 1 is printed in the modal, how can i do that?
tks a lot for the help!!

If the result is a separate page, your JavaScript code didn’t work. Else you’d get alert with “done”. Try debugging it.

On the premise that I’m taking my first steps with java…
would you be so kind as to tell me where I can find an example of a modal form that saves a datum and stays on the same page?
That I searched the wiki and the forum but found nothing

I don’t have ready to use example.

Hi!
Sorry i dont have understand.