<?php
namespace ModulesGarden\Servers\ZimbraEmail\App\UI\Client\DistributionList\Sections;
use ModulesGarden\Servers\ZimbraEmail\App\UI\Admin\Custom\Sections\FreeFieldsSection;
use ModulesGarden\Servers\ZimbraEmail\App\Validators\EmailValidator;
use ModulesGarden\Servers\ZimbraEmail\App\Validators\TaggerEmailValidator;
use function ModulesGarden\Servers\ZimbraEmail\Core\Helper\di;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\Hidden;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\Select;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\Tagger;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\Text;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\Textarea;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Sections\InputGroup;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\InputGroupElements\Text as InputText;

/**
 * Class Members
 * User: Nessandro
 * Date: 2019-09-20
 * Time: 12:42
 */

class AddMembersDistribution extends FreeFieldsSection
{
    protected $id   = 'addMembersDistribution';
    protected $name = 'addMembersDistribution';

    public function initContent()
    {

        $email = new InputGroup('usernameGroup');
        $email->addTextField('listmail', false, true);
        $email->addInputAddon('emailSign', false, '@');
        $email->addInputComponent((new InputText('domain'))->addHtmlAttribute('readonly','true'));
        $this->addSection($email);

        $this->addField((new Text('displayName')));

        $this->addField(new Textarea('description'));

        $this->addField((new Select('memberList'))->enableMultiple());

        $this->addField((new Tagger('customMember'))
            ->setPlaceholder(di('lang')->absoluteT('mail@example.com'))
            ->addValidator(new TaggerEmailValidator())
        );


    }
}