Revision #126 was created by rackycz on Oct 4, 2019, 11:55:18 AM.
contact
Content
[...]
---
- Delete file web/index-test.php
- In file web/index.php comment you 2 first lines containing YII_DEBUG + YII_ENV
- Delete the text from view site/login which says "You may login with admin/admin or demo/demo."
**Saving contact inqueries into DB**
---
```SQL
DROP TABLE IF EXISTS `contact` ;
CREATE TABLE IF NOT EXISTS `contact` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
`email` VARCHAR(45) NOT NULL,
`subject` VARCHAR(100) NOT NULL,
`body` TEXT NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
```
- Create the DB table
- Generate Model + CRUD using GII
- In Site controller replace ContactForm with Contact (in section "use" and in actionContact) and in the action change the IF condition:
```php
use app\models\Contact;
// ...
public function actionContact() {
$model = new Contact();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
// ...
```
- Open the new contact model and add one attribute, 2 rules
``php
public $verifyCode;
// ...
['verifyCode', 'captcha'],
['email', 'email'],
// and translation for Captcha
'verifyCode' => Yii::t('app', 'Verification'),
```
- You can also delete one paragraph from view/site/contact