Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
9350 eleazar 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form;
6
 
7
use Laminas\Form\Form;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use Laminas\Log\LoggerInterface;
10099 eleazar 10
use LeadersLinked\Mapper\TopicMapper;
9350 eleazar 11
 
12
class MyTrainerQuestionForm extends Form
13
{
14
 
10189 eleazar 15
    public function __construct($adapter)
9350 eleazar 16
    {
17
        parent::__construct();
10243 eleazar 18
        $this->setInputFilter(new MyTrainerQuestionFilter($adapter));
9350 eleazar 19
 
20
        $this->add([
21
            'name' => 'title',
22
            'type' => \Laminas\Form\Element\Text::class,
23
             'attributes' => [
24
                'id' 			=> 'title',
25
            ]
26
        ]);
27
 
28
        $this->add([
29
            'name' => 'text',
30
            'type' => \Laminas\Form\Element\Textarea::class,
31
            'attributes' => [
32
                'id'    => 'text',
33
            ]
34
        ]);
35
 
10242 eleazar 36
        $this->add([
37
            'name' => 'category_id',
38
            'type' => \Laminas\Form\Element\Select::class,
39
            'attributes' => [
40
                'id' => 'category_id',
11281 eleazar 41
                'multiple' => 'yes',
10242 eleazar 42
            ],
43
            'options' => [
11280 eleazar 44
                'disable_inarray_validator' => true,
10242 eleazar 45
                'value_options' => $this->getSelectFormOptions($adapter)
46
            ]
47
        ]);
9350 eleazar 48
 
49
    }
50
 
51
     /**
52
     *
53
     * @param AdapterInterface $adapter
54
     */
10113 eleazar 55
    private function getSelectFormOptions($adapter)
9350 eleazar 56
    {
57
        $options = [];
58
 
10099 eleazar 59
        $mapper = TopicMapper::getInstance($adapter);
10113 eleazar 60
        $records = $mapper->fetchAllMyTrainer();
9350 eleazar 61
 
62
        foreach($records as $record)
63
        {
64
            $options[$record->uuid] = $record->title;
65
        }
66
        return $options;
67
    }
68
}