<?php

namespace ModulesGarden\Servers\ZimbraEmail\App\UI\Client\EmailAccount\Forms;


use ModulesGarden\Servers\ZimbraEmail\App\UI\Client\EmailAccount\Providers\EditAccountDataProvider;
use ModulesGarden\Servers\ZimbraEmail\App\Validators\PasswordsValidator;
use ModulesGarden\Servers\ZimbraEmail\App\Validators\RepeatPasswordValidator;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Interfaces\ClientArea;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\BaseForm;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\Hidden;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\Password;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\Select;

/**
 *
 * Created by PhpStorm.
 * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
 * Date: 08.11.19
 * Time: 12:07
 * Class ChangePasswordForm
 */
class ChangePasswordForm extends BaseForm implements ClientArea
{


    protected $id    = 'changePasswordForm';
    protected $name  = 'changePasswordForm';
    protected $title = 'changePasswordForm';

    protected function getDefaultActions()
    {
        return ['changePassword'];
    }

    public function initContent()
    {
        $this->setFormType('changePassword');
        $this->dataProvider = new EditAccountDataProvider();

        $field = new Hidden('id');
        $this->addField($field);

        /**end**/
        $field = new Password('password');
        $field->setDescription('description');
        $field->addValidator(new PasswordsValidator());
        $field->notEmpty();
        $this->addField($field);

        $field = (new Password('repeat_password'))->addValidator(new RepeatPasswordValidator());
        $field->notEmpty();
        $this->addField($field);

        $this->loadDataToForm();
    }

}