Proyectos de Subversion LeadersLinked - Services

Rev

Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
312 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 HabitSkillRegisterForm 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();
25
        $this->setInputFilter(new HabitSkillRegisterFilter());
26
 
27
        $this->add([
28
            'name' => 'date',
29
            'type' => \Laminas\Form\Element\Text::class,
30
            'attributes' => [
31
                'id'    => 'date',
32
                'maxlength' => 10
33
            ]
34
        ]);
35
 
36
        $this->add([
37
            'name' => 'skill_id',
38
            'type' => \Laminas\Form\Element\Select::class,
39
            'options' => [
40
                'value_options' => $this->getOptionsSkillId($adapter, $user_id),
41
            ],
42
            'attributes' => [
43
                'id' => 'intelligence',
44
            ]
45
        ]);
46
 
47
 
48
 
49
        $this->add([
50
            'name' => 'quantitative_value',
51
            'type' => \Laminas\Form\Element\Text::class,
52
            'attributes' => [
53
                'id'    => 'quantitative_value',
54
                'maxlength' => 5
55
            ]
56
        ]);
57
 
58
 
59
 
60
        $this->add([
61
            'name' => 'qualitative_description',
62
            'type' => \Laminas\Form\Element\Text::class,
63
            'attributes' => [
64
                'id'    => 'qualitative_description',
65
                'maxlength' => 50
66
            ]
67
        ]);
68
 
69
 
70
 
71
 
72
 
73
 
74
    }
75
 
76
    /**
77
     *
78
     * @param \Laminas\Db\Adapter\AdapterInterface $ad
79
     * @param int $user_id
80
     */
81
    private function getOptionsSkillId($adapter, $user_id)
82
    {
83
        $items = [];
84
        $mapper = \LeadersLinked\Mapper\HabitSkillMapper::getInstance($adapter);
85
        $records = $mapper->fetchAllByUserId($user_id);
86
        foreach($records as $record)
87
        {
88
            $items[ $record->uuid] = $record->name;
89
         }
90
 
91
         return $items;
92
    }
93
}