<?php
namespace ThurData\Servers\KerioEmail\App\UI\Client\DomainAlias\Forms;

use ThurData\Servers\KerioEmail\App\UI\Admin\Custom\Forms\SortedFieldForm;
use ThurData\Servers\KerioEmail\App\UI\Client\DomainAlias\Providers\AddDomainAliasDataProvider;
use ThurData\Servers\KerioEmail\Core\UI\Interfaces\ClientArea;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Hidden;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\InputGroupElements\Text as InputText;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\FormConstants;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Sections\InputGroup;

/**
 *
 * Created by PhpStorm.
 * User: ThurData
 * 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('alias')));
        $email->addInputAddon('emailSign', false, '→');
        $email->addInputComponent((new InputText('domain'))->addHtmlAttribute('readonly','true'));
        $this->addSection($email);

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

    }
}