Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 17112 | Rev 17178 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
17002 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\Microlearning;
6
 
7
use Laminas\Form\Form;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use Laminas\Log\LoggerInterface;
10
use LeadersLinked\Mapper\CompanySizeMapper;
11
use LeadersLinked\Mapper\IndustryMapper;
12
use LeadersLinked\Model\Feed;
13
use LeadersLinked\Model\MicrolearningTopic;
17112 stevensc 14
use LeadersLinked\Mapper\MicrolearningCapsuleMapper;
17110 stevensc 15
use Laminas\Form\Element\Select;
17002 efrain 16
 
17
class TopicAddForm extends Form
18
{
17110 stevensc 19
    public function __construct($adapter, $company_id)
17002 efrain 20
    {
21
        parent::__construct();
17110 stevensc 22
        $this->setInputFilter(new TopicAddFilter($adapter));
17002 efrain 23
 
24
        $this->add([
25
            'name' => 'name',
26
            'type' => \Laminas\Form\Element\Textarea::class,
27
            'attributes' => [
28
                'id'    => 'name',
29
            ]
30
        ]);
31
 
32
        $this->add([
33
            'name' => 'description',
34
            'type' => \Laminas\Form\Element\Textarea::class,
35
            'attributes' => [
36
                'id'    => 'description',
37
            ]
38
        ]);
39
 
40
        $this->add([
41
            'name' => 'order',
42
            'type' => \Laminas\Form\Element\Text::class,
43
            'attributes' => [
44
                'id'    => 'order',
45
            ],
46
        ]);
47
 
48
        $this->add([
49
            'name' => 'file',
50
            'type' => \Laminas\Form\Element\Hidden::class,
51
            'attributes' => [
52
                'id' => 'file',
53
            ]
17110 stevensc 54
        ]);
17002 efrain 55
 
56
        $this->add([
57
            'name' => 'status',
58
            'type' => \Laminas\Form\Element\Select::class,
59
            'options' => [
60
                'empty_option' => 'LABEL_STATUS',
61
                'value_options' => [
62
                    MicrolearningTopic::STATUS_ACTIVE => 'LABEL_ACTIVE',
63
                    MicrolearningTopic::STATUS_INACTIVE => 'LABEL_INACTIVE',
64
                ],
65
            ],
66
            'attributes' => [
67
                'id' => 'status',
68
            ]
69
        ]);
70
 
17110 stevensc 71
        $this->add([
72
            'name' => 'capsule_uuid',
73
            'type' => Select::class,
74
            'attributes' => [
75
                'multiple' 	=> 'yes',
76
                'id' =>  'capsule_uuid',
77
            ],
78
            'options' => [
79
                'disable_inarray_validator' => true,
80
                'value_options' => $this->getSelectOptions($adapter, $company_id)
81
            ]
82
        ]);
17130 stevensc 83
 
84
        $this->add([
85
            'name' => 'capsule_id',
86
            'type' => Select::class,
87
            'attributes' => [
88
                'multiple' 	=> 'yes',
89
                'id' =>  'capsule_uuid',
90
            ],
91
            'options' => [
92
                'disable_inarray_validator' => true,
93
                'value_options' => $this->getSelectOptions($adapter, $company_id)
94
            ]
95
        ]);
17002 efrain 96
    }
17112 stevensc 97
 
98
    private function getSelectOptions($adapter, $company_id)
99
    {
100
        $options = [];
101
 
102
        $mapper = MicrolearningCapsuleMapper::getInstance($adapter);
103
        $records = $mapper->fetchAllActiveByCompanyId($company_id);
104
 
105
        foreach($records as $record)
106
        {
107
            $options[$record->uuid] = $record->name;
108
        }
109
        return $options;
110
    }
17002 efrain 111
}