如何在yii2中创建新的弹出式联系人表单?
我是Yii2的新手,我正在创建如何在yii2中创建新的弹出式联系人表单?,yii2,Yii2,我是Yii2的新手,我正在创建广告项目。我需要在我的详细视图中插入一个按钮,该按钮将打开一个新的弹出窗口与project上传程序的联系表单。我该怎么做?也许有什么小部件可以解决这个问题?您可以使用引导模式 首先创建如下简单按钮: 开放模态 然后您应该创建模态 在操作视图中,不要忘记初始化ContactForm,如: 公共职能行动索引() { //一些代码 返回$this->render('index',['models'=>$models,'modelContact'=>newcontact
广告项目。我需要在我的详细视图
中插入一个按钮,该按钮将打开一个新的弹出窗口
与project上传程序的联系表单
。我该怎么做?也许有什么小部件可以解决这个问题?您可以使用引导模式
首先创建如下简单按钮:
开放模态
然后您应该创建模态
在操作视图中,不要忘记初始化ContactForm,如:
公共职能行动索引()
{
//一些代码
返回$this->render('index',['models'=>$models,'modelContact'=>newcontactform]);
}
更多关于模态引导的例子是
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<div class="blog-form">
<?php $form = ActiveForm::begin(
[
'id' => 'my-form-id',
'action' => Url::to(['site/contact']),
'enableAjaxValidation' => true,
'validationUrl' => Url::to(['site/contact-validate']),
]
); ?>
<h2 id="conatcth"><strong><?= Yii::t('app', 'contact_us') ?></strong></h2>
<h5 id="h5"><?= Yii::t('app', 'contact_us_description') ?></h5>
<?= $form->field($modelContact, 'name')->textInput(['placeholder' => Yii::t('app', 'Name')])->label(false) ?>
<?= $form->field($modelContact, 'email')->textInput(['placeholder' => Yii::t('app', 'Email')])->label(false) ?>
<?= $form->field($modelContact, 'phone_number')->textInput(['placeholder' => Yii::t('app', 'Phone number')])->label(false) ?>
<?= $form->field($modelContact, 'body')->textarea(['placeholder' => Yii::t('app', 'Body')])->label(false) ?>
<?= $form->field($modelContact, 'not_robot')->checkbox(['checked' => false]) ?>
<div class="form">
<input type="submit" class="btn btn-primary" value="<?= Yii::t('app', 'send') ?>">
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
public function actionContact()
{
$model = new ContactForm();
$request = \Yii::$app->getRequest();
if ($request->isPost && $model->load($request->post())) {
\Yii::$app->response->format = Response::FORMAT_JSON;
$model->contact(Yii::$app->params['adminEmail']); //Send
return $this->redirect(Yii::$app->request->referrer);
}
return $this->redirect(Yii::$app->request->referrer);
}