A
A
AlexSer2019-04-03 13:41:26
Yii
AlexSer, 2019-04-03 13:41:26

How to solve modal window and form issue in Yii2?

I have two modal windows on my page. Both with form. For some reason, in the first modal window, the form tags are displayed normally in the browser. But in the second there are no form tags. What could be the problem?

<ol class="breadcrumb"><li><a href="#">3. Перечень лекарственных препаратов для медицинского применения, зарегистрированных на территории
            Российской Федерации, с указанием средних суточных и курсовых доз</a></li></ol>
<?
Modal::begin([
    'header' => '<h4>Добавление медикаментов</h4>',
    'options' => [
        'id' => 'modal_medikaments',
        'tabindex' => false // important for Select2 to work properly
    ],
    'footer' =>Html::submitButton('Сохранить', ['class' => 'btn btn-primary']),
]);

echo Html::beginForm(['/operation/addmedikaments?id='.$_GET['id']],'get',['name'=>'add_medikaments']);
Html::endForm();
Modal::end();

?>


Вот второе:
<?
Modal::begin([
    'header' => '<h4>Добавление услуги</h4>',
    'options' => [
        'id' => 'modal_med_usluga',
        'tabindex' => false // important for Select2 to work properly
    ],
    'footer' =>Html::submitButton('Сохранить', ['class' => 'btn btn-primary']),
]);
echo Html::beginForm(['/operation/addmed_uslugi?id='.$_GET['id']],'post',['name'=>'add_med_usluga1'], ['enctype' => 'multipart/form-data']);

Html::endForm();
Modal::end();

?>

<?php
$js = <<< JS
$('#add_med_usluga').click(function() {
    $('#modal_med_usluga').modal('show');
  
});

$('#add_medicaments').click(function() {
    $('#modal_medikaments').modal('show');
  
});

JS;
$this->registerJs( $js, $position = yii\web\View::POS_READY, $key = null );
?>​

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question