<?php
namespace ModulesGarden\Servers\ZimbraEmail\App\UI\Client\DomainAlias\Forms;
use ModulesGarden\Servers\ZimbraEmail\App\UI\Admin\Custom\Forms\SortedFieldForm;
use ModulesGarden\Servers\ZimbraEmail\App\UI\Client\DomainAlias\Providers\AddDomainAliasDataProvider;
use ModulesGarden\Servers\ZimbraEmail\App\UI\Client\DomainAlias\Providers\AddListDataProvider;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Interfaces\ClientArea;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\Hidden;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\InputGroupElements\Text as InputText;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\Text;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\FormConstants;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Sections\InputGroup;

/**
 *
 * Created by PhpStorm.
 * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
 * Date: 18.09.19
 * Time: 13:38
 * Class AddDomainAliasForm
 */
class AddDomainAliasForm extends SortedFieldForm implements ClientArea
{
    protected $id    = 'addDomainAliasForm';
    protected $name  = 'addDomainAliasForm';

    public function initContent()
    {
        $this->setFormType(FormConstants::CREATE);
        $this->setProvider(new AddDomainAliasDataProvider());
        $this->initFields();
        $this->loadDataToForm();
    }

    protected function initFields()
    {
        $email = new InputGroup('aliasGroup');
        $email->addInputComponent((new InputText('domain'))->addHtmlAttribute('readonly','true'));
        $email->addInputAddon('emailSign', false, '→');
        $email->addInputComponent((new InputText('alias')));
        $this->addSection($email);

        $this->addField((new Text('description'))->setDescription('descriptionDomainList'));

        /**
         * hidden fields
         */
        $this->addField((new Hidden('domainId')));

    }
}