<?php

namespace ThurData\Servers\KerioEmail\App\UI\Client\Ressource\Forms;

use ThurData\Servers\KerioEmail\App\UI\Client\Ressource\Providers\EditRessourceDataProvider;
use ThurData\Servers\KerioEmail\App\Validators\PasswordsValidator;
use ThurData\Servers\KerioEmail\App\Validators\RepeatPasswordValidator;
use ThurData\Servers\KerioEmail\Core\UI\Interfaces\ClientArea;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\BaseForm;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Hidden;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Password;

/**
 *
 * Created by PhpStorm.
 * User: ThurData
 * 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 EditRessourceDataProvider();

        $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();
    }

}