Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16766 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

<?php

declare(strict_types=1);

namespace LeadersLinked\Form\Network;

use Laminas\Form\Form;
use Laminas\Db\Adapter\AdapterInterface;
use Laminas\Log\LoggerInterface;
use LeadersLinked\Mapper\ThemeMapper;
use LeadersLinked\Model\Network;

class NetworkEditForm extends Form
{

    /**
     * 
     * @param AdapterInterface $adapter
     */
    public function __construct($adapter) 
    {
        
        parent::__construct();
        $this->setInputFilter(new NetworkEditFilter($adapter));
        
      
        $this->add([
            'name' => 'name',
            'type' => \Laminas\Form\Element\Text::class,
             'attributes' => [
                'maxlength'     => 128,
                'id'                    => 'name',
            ]
         ]);

        $this->add([
            'name' => 'main_hostname',
            'type' => \Laminas\Form\Element\Text::class,
            'attributes' => [
                'maxlength'     => 250,
                'id'                    => 'main_hostname',
            ]
        ]);
        
        $this->add([
            'name' => 'alternative_hostname',
            'type' => \Laminas\Form\Element\Text::class,
            'attributes' => [
                'maxlength'     => 250,
                'id'                    => 'alternative_hostname',
            ]
        ]);
        
        
        
        $this->add([
            'name' => 'admin_hostname',
            'type' => \Laminas\Form\Element\Text::class,
            'attributes' => [
                'maxlength'     => 250,
                'id'                    => 'admin_hostname',
            ]
        ]);
        
        $this->add([
            'name' => 'status',
            'type' => \Laminas\Form\Element\Checkbox::class,
            'attributes' => [
                'id'                    => 'status',
            ],
            'options' => [
                'use_hidden_element' => 0,
                'unchecked_value' => \LeadersLinked\Model\Network::STATUS_INACTIVE,
                'checked_value'=> \LeadersLinked\Model\Network::STATUS_ACTIVE,
            ]
        ]);
        
        $this->add([
            'name' => 'moodle_url',
            'type' => \Laminas\Form\Element\Text::class,
            'attributes' => [
                'maxlength'     => 250,
                'id'                    => 'moodle_url',
            ]
        ]);
        
        
        $this->add([
            'name' => 'relationship_user_mode',
            'type' => \Laminas\Form\Element\Select::class,
            'attributes' => [
                'id' => 'relationship_user_mode',
            ],
            'options' => [
                'value_options' => [
                    Network::RELATIONSHIP_USER_MODE_USER_2_USER => 'LABEL_RELATIONSHIP_USER_MODE_USER_2_USER',
                    Network::RELATIONSHIP_USER_MODE_ALL_2_ALL => 'LABEL_RELATIONSHIP_USER_MODE_ALL_2_ALL',
                ]
            ]
        ]);

        
        $this->add([
            'name' => 'theme_id',
            'type' => \Laminas\Form\Element\Select::class,
            'attributes' => [
                'id' => 'theme_id',
            ],
            'options' => [
                'disable_inarray_validator' => true,
                'value_options' => $this->optionsTheme($adapter)
            ]
        ]);
        
        
    }
    
    /**
     *
     * @param AdapterInterface $adapter
     */
    private function optionsTheme($adapter)
    {
        $options = [];
        
        $mapper = ThemeMapper::getInstance($adapter);
        $records = $mapper->fetchAll();
        
        foreach($records as $record)
        {
            $options[$record->uuid] = $record->name;
        }
        return $options;
    }
    
    
   
}