/var/www/vhosts/ihelp.ro/httpdocs/src/Form
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Form/ContactForm.php (1736B)
addField('name', 'string')
->addField('email', ['type' => 'string'])
->addField('message', ['type' => 'text']);
}
/**
* Form validation builder
*/
public function validationDefault(Validator $validator): Validator
{
$validator
->scalar('name')
->maxLength('name', 255)
->requirePresence('name', 'create')
->notEmptyString('name', __('Acest câmp nu poate fi lăsat gol'));
$validator
->email('email')
->maxLength('email', 255)
->requirePresence('email', 'create')
->notEmptyString('email', __('Acest câmp nu poate fi lăsat gol'));
$validator
->scalar('message')
->maxLength('message', 3000)
->requirePresence('message', 'create')
->notEmptyString('message', __('Acest câmp nu poate fi lăsat gol'));
return $validator;
}
/**
* Defines what to execute once the Form is processed
*/
protected function _execute(array $data): bool
{
$return = false;
try {
$this->getMailer('Form')->send('contact', [$data]);
$return = true;
} catch (\Throwable $th) {
//throw $th;
}
return $return;
}
}