Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
16248 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\KnowledgeArea;
6
 
7
use Laminas\Form\Form;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use LeadersLinked\Mapper\KnowledgeAreaCategoryMapper;
10
 
11
 
12
class KnowledgeAreaCategoryUserDataForm extends Form
13
{
14
 
15
    /**
16
     *
17
     * @param AdapterInterface $adapter
18
     * @param int $company_id
19
     */
20
    public function __construct($adapter, $company_id) {
21
        parent::__construct();
22
        $this->setInputFilter(new KnowledgeAreaCategoryUserDataFilter());
23
 
24
 
25
 
26
 
27
        $this->add([
28
            'name' => 'category_id',
29
            'type' => \Laminas\Form\Element\Select::class,
30
            'attributes' => [
31
                'id' =>  'category_id',
32
            ],
33
            'options' => [
34
                //'disable_inarray_validator' => true,
35
                'value_options' =>  $this->getCategories($adapter, $company_id)
36
            ]
37
        ]);
38
 
39
 
40
 
41
    }
42
 
43
    private function getCategories($adapter, $company_id)
44
    {
45
        $items = [];
46
        $knowledgeAreaCategoryMapper = KnowledgeAreaCategoryMapper::getInstance($adapter);
47
        $records = $knowledgeAreaCategoryMapper->fetchAllByCompanyId($company_id);
48
 
49
        foreach($records as $record)
50
        {
51
            $items[ $record->uuid ] = $record->name;
52
        }
53
 
54
        return $items;
55
    }
56
 
57
 
58
}
59