Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 17087 | Rev 17090 | 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\Model\Topic;
11
use Laminas\Form\Element;
12
 
17082 stevensc 13
use LeadersLinked\Mapper\MicrolearningCapsuleMapper;
17002 efrain 14
 
15
class TopicForm extends Form
16
{
17
 
17080 stevensc 18
    public function __construct($adapter, $company_id){
17002 efrain 19
        parent::__construct();
17087 stevensc 20
        $this->setInputFilter(new TopicFilter($adapter));
17002 efrain 21
 
22
 
17080 stevensc 23
        $this->add([
17086 stevensc 24
            'name' => 'capsules_uuid',
17080 stevensc 25
            'type' => \Laminas\Form\Element\Select::class,
26
            'attributes' => [
17086 stevensc 27
                'id' => 'capsules_uuid',
17080 stevensc 28
            ],
29
            'options' => [
30
                'value_options' => $this->getSelectOptions($adapter, $company_id)
31
            ]
32
        ]);
33
 
17002 efrain 34
 
35
 
36
         $this->add([
37
            'name' => 'title',
38
            'type' => \Laminas\Form\Element\Text::class,
39
            'attributes' => [
40
                'maxlength' 	=> 128,
41
                'id' 			=> 'title',
42
            ]
43
        ]);
44
 
45
       $this->add([
46
            'name' => 'description',
47
            'type' => \Laminas\Form\Element\Textarea::class,
48
            'attributes' => [
49
                'id'    => 'description',
50
            ]
51
        ]);
52
 
53
        $this->add([
54
            'name' => 'status',
55
            'type' => \Laminas\Form\Element\Checkbox::class,
56
            'attributes' => [
57
                'id' 			=> 'status',
58
            ],
59
            'options' => [
60
                'use_hidden_element' => false,
61
                'unchecked_value' => \LeadersLinked\Model\Topic::STATUS_INACTIVE,
62
                'checked_value'=> \LeadersLinked\Model\Topic::STATUS_ACTIVE,
63
            ]
64
        ]);
65
    }
66
 
17080 stevensc 67
    private function getSelectOptions($adapter, $company_id)
68
    {
69
        $options = [];
70
 
71
        $mapper = MicrolearningCapsuleMapper::getInstance($adapter);
72
        $records = $mapper->fetchAllActiveByCompanyId($company_id);
73
 
74
        foreach($records as $record)
75
        {
76
            $options[$record->uuid] = $record->name;
77
        }
17086 stevensc 78
        return $options;
17080 stevensc 79
    }
80
 
17002 efrain 81
}
82