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

/**
 * Class Members
 * User: ThurData
 * 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 Textarea('description'));

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

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

    }
}