mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-12 23:35:50 +00:00
git-subtree-dir: community_server git-subtree-mainline: ff11f6efe35bba180260fe84077bcd94298895c1 git-subtree-split: b6544b9e69fb85d4da100934675323c3e8c8ef67
53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
// in src/Form/ProfileForm.php
|
|
namespace App\Form;
|
|
|
|
use Cake\Form\Form;
|
|
use Cake\Form\Schema;
|
|
use Cake\Validation\Validator;
|
|
|
|
class ProfileForm extends Form
|
|
{
|
|
|
|
protected function _buildSchema(Schema $schema)
|
|
{
|
|
return $schema
|
|
->addField('first_name', ['type' => 'string'])
|
|
->addField('last_name', ['type' => 'string'])
|
|
->addField('profile_img', ['type' => 'string'])
|
|
->addField('profile_desc', ['type' =>'text', 'default' => '', 'rows' => 10, 'maxlength' => 2000]);
|
|
}
|
|
|
|
function validationDefault(Validator $validator)
|
|
{
|
|
$validator->setProvider('generic', 'App\Model\Validation\GenericValidation');
|
|
$validator->add('first_name', 'length', [
|
|
'rule' => ['maxLength', 255],
|
|
'message' => __('The first name should contain max 255 characters')
|
|
])
|
|
->add('last_name', 'length', [
|
|
'rule' => ['maxLength', 255],
|
|
'message' => __('The last name should contain max 255 characters')
|
|
])
|
|
->add('profile_desc', 'length', [
|
|
'rule' => ['maxLength', 2000],
|
|
'message' => __('The description should contain max 2000 characters')
|
|
])
|
|
->add('profile_desc', 'generic', [
|
|
'rule' => 'alphaNumeric',
|
|
'provider' => 'generic',
|
|
'message' => __('No HTML Tags like > or < please.')
|
|
])
|
|
->allowEmptyString('profile_img', null, 'create')
|
|
->allowEmptyString('profile_desc', null, 'create')
|
|
;
|
|
return $validator;
|
|
}
|
|
|
|
protected function _execute(array $data)
|
|
{
|
|
// Send an email. (??? xxx)
|
|
return true;
|
|
}
|
|
}
|