-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yii\bootstrap\Modal should render the modal HTML at the end of the page body #7189
Comments
this can be done using the dealing with the Modal::begin([
'header' => '<b>' . Yii::t('app', 'Create new project') . '</b>',
'footer' => Html::submitButton(Yii::t('app', 'Save')),
]);
$form = ActiveForm::begin();
echo $form->field($model, 'proyecto');
ActiveForm::end();
Modal::end(); In this case the submitButton will be rendered outside the active form, so clicking not do anything unless you also write your own code in js. The best way to solve it is to start the $form = ActiveForm::begin();
Modal::begin([
'header' => '<b>' . Yii::t('app', 'Create new project') . '</b>',
'footer' => Html::submitButton(Yii::t('app', 'Save')) . ' '
. $form->field($model, 'subscribe'), // Subscribe checkbox
]);
echo $form->field($model, 'proyecto');
Modal::end();
ActiveForm::end(); Using On your layout $this->beginBlock('modalContainer', true);
$this->endBlock(); Then on your view $this->beginBlock('modalContainer');
$form = ActiveForm::begin();
Modal::begin([
'header' => '<b>' . Yii::t('app', 'Create new project') . '</b>',
'footer' => Html::submitButton(Yii::t('app', 'Save')) . ' '
. $form->field($model, 'subscribe'), // Subscribe checkbox
]);
echo $form->field($model, 'proyecto');
Modal::end();
ActiveForm::end();
$this->endBlock() |
@Faryshta the problem with the Block solution is that Modal currently outputs both toggleLink and modal structure right away. I could use the Block to place the Modal outside my form, but then the toggleLink will be outside too. |
How I solved that same issue // put this anywhere you want, it will create your modal button
<?= Html::button(Yii::t('app', 'New User'), [
// other options
'data' => [
'toggle' => 'modal',
'target' => '#userModal',
],
]) ?> And the modal widget will look like Modal::begin([
'id' => '#userModal',
// other options
]);
// content
Modal::end(); |
Issue moved to yiisoft/yii2-bootstrap#109 |
Scenario : I'm in a form (A), and I use yii\bootstrap\Modal to open a new form (B) used to add a new option in my dropDownList() located in A. (see attached screenshot for better understanding)
I want the modal toggle button to be displayed near the dropDownList(), so I go ahead and do :
Problem : when generated, the B form will be nested in the A form, which brakes things.
Possible solution : a possible solution would be to render the toggleButton right away, as it is done now, but delay all the modal markup & content to View::EVENT_END_BODY, to make sure that if the modal contains a form, it won't be nested in an other one.
I'd cook a patch but I'm not sure how the modal content should be captured with Yii development guidelines. Please advise if a patch like this would be acceptable.
The text was updated successfully, but these errors were encountered: