PHP code example of luyadev / luya-module-contactform

1. Go to this page and download the library: Download luyadev/luya-module-contactform library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

luyadev / luya-module-contactform example snippets


'modules' => [
    // ...
    'contactform' => [
        'class' => 'luya\contactform\Module',
        'useAppViewPath' => true, // When enabled the views will be looked up in the @app/views folder, otherwise the views shipped with the module will be used.
        'mailTitle' => 'Contact Form',
        'attributes' => [
            'name', 'email', 'street', 'city', 'tel', 'message',
        ],
        'rules' => [
            [['name', 'email', 'street', 'city', 'message'], '

'attributeLabels' => [
    'email' => 'E-Mail',
],



use yii\widgets\ActiveForm;
use yii\helpers\Html;

/** @var \yii\base\Model $model Contains the model object based on DynamicModel yii class. */
/** @var \luya\web\View $this The current View object */
/** @var ActiveForm $form The ActiveForm Object */

SubmitButtonWidget::widget(['label' => 'Send', 'pushed' => 'Sending...', 'activeForm' => $form, 'options' => ['class' => 'btn btn-primary']]);

'modules' => [
    // ...
    'contactform' => [
        // ...
        'callback' => function($model) {
            // insert the name of each contact form into `contact_form_requests` table:
            Yii::$app->db->createCommand()->insert('contact_form_requests', ['name' => $model->name])->execute();
        }
    ],
];

'modules' => [
    // ...
    'contactform' => [
        // ...
        'detailViewAttributes' => ['name', 'newsletter:bool', 'city', 'message:text:Label for Message'],    
       // ...
    ],
];

'modules' => [
    // ...
    'contactform' => [
        // ...
        'detailViewAttributes' => [
            ['attribute' => 'name'],
            ['attribute' => 'email'],
            ['attribute' => 'newsletter:bool'],
            ['attribute' => 'city:integer'],
            ['attribute' => 'message'],
        ],       
       // ...
    ],
];