Proyectos de Subversion LeadersLinked - Services

Rev

Rev 307 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
307 www 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\Habit;
6
 
7
 
8
use Laminas\Form\Form;
9
use Laminas\Db\Adapter\AdapterInterface;
10
use Laminas\Log\LoggerInterface;
11
use LeadersLinked\Mapper\CompanySizeMapper;
12
use LeadersLinked\Mapper\IndustryMapper;
13
use LeadersLinked\Model\Feed;
14
 
15
class HabitGoalForm extends Form
16
{
17
    /**
18
     *
19
     * @param \Laminas\Db\Adapter\AdapterInterface $adapter
20
     * @param int $user_id
21
     */
22
    public function __construct($adapter, $user_id)
23
    {
24
        parent::__construct();
308 www 25
        $this->setInputFilter(new HabitGoalFilter($adapter, $user_id));
307 www 26
 
27
        $this->add([
28
            'name' => 'name',
29
            'type' => \Laminas\Form\Element\Text::class,
30
            'attributes' => [
31
                'id'    => 'name',
32
                'maxlength' => 100
33
            ]
34
        ]);
35
 
36
        $this->add([
308 www 37
            'name' => 'description',
38
            'type' => \Laminas\Form\Element\Textarea::class,
39
            'attributes' => [
40
                'id'    => 'description',
41
                'maxlength' => 512
42
            ]
43
        ]);
44
 
45
        $this->add([
46
            'name' => 'value',
47
            'type' => \Laminas\Form\Element\Text::class,
48
            'attributes' => [
49
                'id'    => 'value',
50
                'maxlength' => 5
51
            ]
52
        ]);
53
 
54
        $this->add([
55
            'name' => 'start_date',
56
            'type' => \Laminas\Form\Element\Text::class,
57
            'attributes' => [
58
                'id'    => 'start_date',
59
                'maxlength' => 20
60
            ]
61
        ]);
62
 
63
        $this->add([
64
            'name' => 'end_date',
65
            'type' => \Laminas\Form\Element\Text::class,
66
            'attributes' => [
67
                'id'    => 'end_date',
68
                'maxlength' => 20
69
            ]
70
        ]);
71
 
72
 
73
 
74
 
75
        $this->add([
307 www 76
            'name' => 'skill_id',
77
            'type' => \Laminas\Form\Element\Select::class,
78
            'attributes' => [
79
                'multiple' 	=> 'yes',
80
                'id' => 'skill_id',
81
            ],
82
            'options' => [
83
                'disable_inarray_validator' => true,
84
                'value_options' => $this->getSelectOptions($adapter, $user_id)
85
            ]
86
        ]);
87
 
88
    }
89
 
90
    private function getSelectOptions($adapter, $user_id)
91
    {
92
        $items = [];
93
 
94
        $habitSkillMapper = \LeadersLinked\Mapper\HabitSkillMapper::getInstance($adapter);
95
        $records = $habitSkillMapper->fetchAllByUserId($user_id);
96
        foreach($records as $record)
97
        {
98
            $items[ $record->uuid ]  = $record->name;
99
        }
308 www 100
 
101
 
307 www 102
        return $items;
103
 
104
    }
105
}