1. Go to this page and download the library: Download luyadev/luya-module-forms 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/ */
'components' => [
//...
'forms' => [
'class' => 'luya\forms\Forms',
'emailMessage' => function (SubmissionEmail $email, Forms $form) {
// your custom mailer integration is here, ensure to return a boolean
// value whether sending was successfull or not!
return \Yii::$app->mailer->compose()
->setFrom(...)
->setTo($email->getRecipients())
->setSubject($email->getSubject())
->setTextBody($email->getBodyText())
->setHtmlBody($email->getBodyHtml())
->send();
}
]
]
'emailMessage' => function (SubmissionEmail $email, Forms $form) {
return Yii::$app->mailer->compose()
->setTo($email->submission->getValueByAttribute('email')) // receives the value from the user entered data.
....
}
class MyDropDownBlock extends PhpBlock
{
use FieldBlockTrait;
public function name()
{
return 'Dropdown';
}
public function admin()
{
return '<p>My Dropdown {{vars.label}}</p>';
}
public function frontend()
{
Yii::$app->forms->autoConfigureAttribute(
$this->getVarValue($this->varAttribute),
$this->getVarValue($this->varRule, $this->defaultRule),
$this->getVarValue($this->varIsRequired),
$this->getVarValue($this->varLabel),
$this->getVarValue($this->varHint)
);
// Use all possible options with ActiveField or use the HtmlHelper
return Yii::$app->forms->form->field(Yii::$app->forms->model, $this->getVarValue($this->varAttribute))
->dropDownList([1 => 'Foo', 2 => 'Bar']);
}
}
./vendor/bin/luya message msgconfig.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.