/
var
/
www
/
vhosts
/
ihelp.ro
/
httpdocs
/
src
/
Form
/
/var/www/vhosts/ihelp.ro/httpdocs/src/Form
mkdir
upload
Name
Size
Mode
Actions
ContactForm.php
1736
0644
edit
dl
rm
FilterForm.php
943
0644
edit
dl
rm
ShareForm.php
1571
0644
edit
dl
rm
Edit:
/var/www/vhosts/ihelp.ro/httpdocs/src/Form/ContactForm.php
(1736B)
<?php declare(strict_types=1); namespace App\Form; use Cake\Form\Form; use Cake\Form\Schema; use Cake\Validation\Validator; use Cake\Mailer\MailerAwareTrait; /** * Contact Form. */ class ContactForm extends Form { use MailerAwareTrait; /** * Builds the schema for the modelless form */ protected function _buildSchema(Schema $schema): Schema { return $schema ->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; } }
Save
cmd:
run