Blame view

src/Form/ConfigurationFieldsForm.php 1.19 KB
3c4f9138   Etienne Pallier   BIG NEW FEATURE: ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
// in src/Form/ContactForm.php
namespace App\Form;

use Cake\Form\Form;
use Cake\Form\Schema;
use Cake\Validation\Validator;
use Cake\Core\Configure;

// modelless form : voir https://book.cakephp.org/3/en/core-libraries/form.html
class ConfigurationFieldsForm extends Form
{
    /*
    protected function _buildSchema(Schema $schema)
    {
        //$fields = Configure::readOrFail('MANDATORY_AND_READONLY_FIELDS');
        //debug($fields);
        //foreach ($fields as $fname=>$val) debug($fname);
        
        return $schema
            ->addField('name', 'string')
            ->addField('email', ['type' => 'string'])
            ->addField('body', ['type' => 'text']);
    }
    */

    /*
    public function validationDefault(Validator $validator)
    {
        $validator->add('name', 'length', [
                'rule' => ['minLength', 5],
                'message' => 'A name is required'
            ])->add('email', 'format', [
                'rule' => 'email',
                'message' => 'A valid email address is required',
            ]);

        return $validator;
    }
    */

    protected function _execute(array $data)
    {
        // Send an email.
        return true;
    }
}