/
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/ShareForm.php
(1571B)
<?php declare(strict_types=1); namespace App\Form; use Cake\Form\Form; use Cake\Form\Schema; use Cake\Validation\Validator; use Cake\Mailer\MailerAwareTrait; /** * Share Form. */ class ShareForm extends Form { use MailerAwareTrait; /** * Builds the schema for the modelless form */ protected function _buildSchema(Schema $schema): Schema { $schema ->addField('email', ['type' => 'string']); return $schema; } /** * Form validation builder */ public function validationDefault(Validator $validator): Validator { $validator ->email('email', true, __('Valoarea furnizată este invalidă')) ->maxLength('email', 255) ->requirePresence('email', 'create') ->notEmptyString('email', __('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('share', [$data]); $return = true; } catch (\Throwable $th) { //throw $th; $errors['email'] = __('Email-ul nu a putut fi trimis. Error #6464686845'); $this->setErrors($errors); } return $return; } /** * setErrors */ public function setErrors($errors) { foreach ($errors as $key => $error) { $this->_errors[$key] = $error; } } }
Save
cmd:
run