<?php
namespace ModulesGarden\Servers\OpenXchange\App\UI\Client\EmailAlias\Forms;
use ModulesGarden\Servers\OpenXchange\Core\UI\Interfaces\ClientArea;
use ModulesGarden\Servers\OpenXchange\Core\UI\Widget\Forms\Fields\Hidden;
use ModulesGarden\Servers\OpenXchange\Core\UI\Widget\Forms\Fields\Select;
use ModulesGarden\Servers\OpenXchange\Core\UI\Widget\Forms\FormConstants;
use ModulesGarden\Servers\OpenXchange\Core\UI\Widget\Forms\Sections\InputGroup;
use ModulesGarden\Servers\OpenXchange\App\UI\Client\Others\Forms\SortedFieldForm;
use ModulesGarden\Servers\OpenXchange\Core\UI\Widget\Forms\Fields\InputGroupElements;
use ModulesGarden\Servers\OpenXchange\App\UI\Client\EmailAccount\Providers\AccountDataProvider;
use ModulesGarden\Servers\OpenXchange\App\UI\Client\EmailAlias\Providers\AddEmailAliasDataProvider;

/**
 *
 * Created by PhpStorm.
 * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
 * Date: 18.09.19
 * Time: 11:50
 * Class AddEmailAliasForm
 */
class AddEmailAliasForm extends SortedFieldForm implements ClientArea
{
    protected $id    = 'addEmailAliasForm';
    protected $name  = 'addEmailAliasForm';
    protected $title = 'addEmailAliasForm';

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

    public function initFields()
    {
        $email = new InputGroup('usernameGroup');

        $email->addTextField('aliasName', false, true);
        $email->addInputAddon('emailSign', false, '@');
        $email->addInputComponent((new InputGroupElements\Text('domain'))->addHtmlAttribute('readonly','true'));
        $this->addSection($email);

        $field = new Select('mailbox');
        $field->notEmpty();
        $this->addField($field);
    }
}