public function actionContact()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('success', 'Спасибо, что связались с нами. Мы ответим Вам в кратчайшие сроки!');
} else {
Yii::$app->session->setFlash('error', 'Произошла ошибка при отправке сообщения.');
}
return $this->refresh();
} else {
return $this->render('contact', [
'model' => $model,
]);
}
}
<?php
Modal::begin([
"size"=>"modal-sm",
"options"=>[
"id"=>"leads",
],
'header' => '<h2>Запись на занятие</h2>',
]);?>
<?php Modal::end();?>
<?php
namespace frontend\models;
use Yii;
use yii\base\Model;
/**
* ContactForm is the model behind the contact form.
*/
class ContactForm extends Model
{
public $name;
public $phone;
public $subject;
public $body;
public $verifyCode;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name', 'phone'], 'required'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'name' => Yii::t('frontend','Name'),
'phone' => Yii::t('frontend','Phone'),
];
}
/**
* Sends an email to the specified email address using the information collected by this model.
*
* @param string $email the target email address
* @return bool whether the email was sent
*/
public function sendEmail($email)
{
return Yii::$app->mailer->compose()
->setTo($email)
->setSubject("Заявка с сайта")
->setTextBody('Имя: '.$this->name.', Телефон: '.$this->phone)
->send();
}
}
<?php
/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \frontend\models\ContactForm */
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\captcha\Captcha;
/*
$this->title = Yii::t('frontend','Contact');
$this->params['breadcrumbs'][] = $this->title;*/
?>
<div class="site-contact">
<selector id="contact-forms">
<div class="container">
<div class="row">
<div class="col-lg-12">
<?php $form = ActiveForm::begin(['id' => 'contact-form']); ?>
<?= $form->field($model, 'name')->textInput(['autofocus' => true]) ?>
<?= $form->field($model, 'phone') ?>
<div class="form-group">
<?= Html::submitButton( Yii::t('frontend','Submit'), ['class' => 'btn btn-primary', 'name' => 'contact-button']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>
</selector>
</div>
<?php Modal::begin([
"id"=>"ajaxCrudModal",
"footer"=>"",// always need it for jquery plugin
])?>
public function getComitetName() {
return $this->hasMany(Comitet::className(), ['id'=> 'judge_id'])
->viaTable('judge-comitet', ['comitet_id' => 'id']);
}
[
'class'=>'\kartik\grid\DataColumn',
'label' => 'Категории',
'value' => function () {
return implode(', ', ArrayHelper::map(\backend\models\Judge::find()->all(), 'id', 'comitetName'));
},
],
public function actionIndex()
{
$searchSetting = new SettingSearch();
$settingProvider = $searchSetting->search(Yii::$app->request->queryParams);
$searchHall = new HallSearch();
$hallProvider = $searchHall->search(Yii::$app->request->queryParams);
$settingProvider->pagination->pageParam = 'setting-page';
$settingProvider->sort->sortParam = 'setting-sort';
$hallProvider->pagination->pageParam = 'hall-page';
$hallProvider->sort->sortParam = 'hall-sort';
return $this->render('index', [
'searchSetting' => $searchSetting,
'settingProvider' => $settingProvider,
'searchHall' => $searchHall,
'hallProvider' => $hallProvider,
]);
}
<div class="hall-index col-sm-6">
<div id="ajaxCrudDatatable">
<?=GridView::widget([
'id'=>'crud-datatable',
'dataProvider' => $hallProvider,
'filterModel' => $searchHall,
'pjax'=>true,
'columns' => require(__DIR__ . '/../hall/_columns.php'),
'toolbar'=> [
['content'=>
Html::a('<i class="glyphicon glyphicon-plus"></i>', ['setting/hall/create'],
['role'=>'modal-remote','title'=> Yii::t('backend', 'Create new'), Yii::t('backend', 'Halls'),'class'=>'btn btn-success']).
Html::a('<i class="glyphicon glyphicon-repeat"></i>', [''],
['data-pjax'=>1, 'class'=>'btn btn-default', 'title'=> Yii::t('backend', 'Refresh')]).
'{toggleData}'.
'{export}'
],
],
'striped' => true,
'condensed' => true,
'responsive' => true,
'panel' => [
'type' => 'primary',
'heading' => false,
/////'before'=>'<em>Yii::t('backend', '* Resize table columns just like a spreadsheet by dragging the column edges.')</em>',
/*'after'=>BulkButtonWidget::widget([
'buttons'=>Html::a('<i class="glyphicon glyphicon-trash"></i>'.' '. Yii::t('backend', 'Delete'),
["bulk-delete"] ,
[
"class"=>"btn btn-danger btn-xs",
'role'=>'modal-remote-bulk',
'data-confirm'=>false, 'data-method'=>false,// for overide yii data api
'data-request-method'=>'post',
'data-confirm-title'=>Yii::t('backend', 'Are you sure?'),
'data-confirm-message'=>Yii::t('backend', 'Are you sure want to delete this item') ]),
]).
'<div class="clearfix"></div>',*/
]
])?>
</div>
</div>
<?=GridView::widget([
'id'=>'crud-datatable',
'dataProvider' => $dataHall,
'filterModel' => $searchHall,
'pjax'=>true,
'columns' => require(__DIR__ . '/../hall/_columns.php'),
'toolbar'=> [
['content'=>
Html::a('<i class="glyphicon glyphicon-plus"></i>', ['create'],
['role'=>'modal-remote','title'=> Yii::t('backend', 'Create new'), Yii::t('backend', 'Halls'),'class'=>'btn btn-success']).
Html::a('<i class="glyphicon glyphicon-repeat"></i>', [''],
['data-pjax'=>1, 'class'=>'btn btn-default', 'title'=> Yii::t('backend', 'Refresh')]).
'{toggleData}'.
'{export}'
],
]
])?>
</div>
[
'class' => 'kartik\grid\ActionColumn',
'controller' => 'setting/hall',
'dropdown' => false,
'vAlign'=>'middle',
'urlCreator' => function($action, $model, $key, $index) {
return Url::to([$action,'id'=>$key]);
},
]