public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $form = new Form();
     $form->setName('login-form');
     $form->add(array('type' => 'hidden', 'name' => 'ref'));
     $fieldset = new Fieldset();
     $fieldset->add(array('name' => 'login', 'options' => array('label' => 'Login name', 'description' => 'Provide your login key (e.g. email adress)')));
     $fieldset->add(array('type' => 'password', 'name' => 'credential', 'options' => array('label' => 'Password')));
     $form->add($fieldset);
     $form->add($this->forms->get('DefaultButtonsFieldset'));
 }
Beispiel #2
0
 public function __construct($name = 'register-form', $options = array())
 {
     parent::__construct($name, $options);
     $this->setAttribute('data-handle-by', 'native');
     $this->setAttribute('class', 'form-horizontal');
     $fieldset = new Fieldset('register');
     $fieldset->setOptions(array('renderFieldset' => true));
     $fieldset->add(array('type' => 'text', 'name' => 'name', 'options' => array('label' => 'Name')));
     $fieldset->add(array('type' => 'email', 'name' => 'email', 'options' => array('label' => 'Email')));
     $fieldset->add(array('name' => 'role', 'type' => 'hidden', 'attributes' => array('value' => User::ROLE_RECRUITER)));
     $this->add($fieldset);
     if (($captchaOptions = $this->getOption('captcha')) && !empty($captchaOptions['use'])) {
         if ($captchaOptions['use'] === 'image' && !empty($captchaOptions['image'])) {
             $captcha = new Image($captchaOptions['image']);
         } elseif ($captchaOptions['use'] === 'reCaptcha' && !empty($captchaOptions['reCaptcha'])) {
             $captcha = new ReCaptcha($captchaOptions['reCaptcha']);
         }
         if (!empty($captcha)) {
             $this->add(array('name' => 'captcha', 'options' => array('label' => 'Are you human?', 'captcha' => $captcha), 'type' => 'Zend\\Form\\Element\\Captcha'));
         }
     }
     $buttons = new ButtonsFieldset('buttons');
     $buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('type' => 'submit', 'value' => 'Register', 'class' => 'btn btn-primary')));
     $this->add(array('name' => 'csrf', 'type' => 'csrf', 'options' => array('csrf_options' => array('salt' => str_replace('\\', '_', __CLASS__), 'timeout' => 3600))));
     $this->add($buttons);
 }
Beispiel #3
0
 public function __construct($name = 'register-form', CaptchaOptions $options, $role = 'recruiter')
 {
     parent::__construct($name, []);
     $this->setAttribute('data-handle-by', 'native');
     $this->setAttribute('class', 'form-horizontal');
     $fieldset = new Fieldset('register');
     $fieldset->setOptions(array('renderFieldset' => true));
     $fieldset->add(array('type' => 'text', 'name' => 'name', 'options' => array('label' => 'Name')));
     $fieldset->add(array('type' => 'email', 'name' => 'email', 'options' => array('label' => 'Email'), 'attributes' => ['required' => true]));
     $fieldset->add(array('name' => 'role', 'type' => 'hidden', 'attributes' => array('value' => $role)));
     $this->add($fieldset);
     $mode = $options->getMode();
     if (in_array($mode, [CaptchaOptions::RE_CAPTCHA, CaptchaOptions::IMAGE])) {
         if ($mode == CaptchaOptions::IMAGE) {
             $captcha = new Image($options->getImage());
         } elseif ($mode == CaptchaOptions::RE_CAPTCHA) {
             $captcha = new ReCaptcha($options->getReCaptcha());
         }
         if (!empty($captcha)) {
             $this->add(array('name' => 'captcha', 'options' => array('label' => 'Are you human?', 'captcha' => $captcha), 'type' => 'Zend\\Form\\Element\\Captcha'));
         }
     }
     $buttons = new ButtonsFieldset('buttons');
     $buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('type' => 'submit', 'value' => 'Register', 'class' => 'btn btn-primary')));
     $this->add(array('name' => 'csrf', 'type' => 'csrf', 'options' => array('csrf_options' => array('salt' => str_replace('\\', '_', __CLASS__), 'timeout' => 3600))));
     $this->add($buttons);
 }
Beispiel #4
0
 protected function addHydratorStrategies($hydrator)
 {
     parent::addHydratorStrategies($hydrator);
     $statusStrategy = new ClosureStrategy(function ($object) {
         return $object->getName();
     });
     $hydrator->addStrategy('status', $statusStrategy);
 }
Beispiel #5
0
 /**
  * configure the formular for uploading attachments
  *
  * @param Form $form
  * @param AbstractOptions $options
  */
 protected function configureForm($form, AbstractOptions $options)
 {
     $form->setIsDisableCapable(false)->setIsDisableElementsCapable(false)->setIsDescriptionsEnabled(true)->setDescription('Attach images or PDF Documents to your application. Drag&drop them, or click into the attachement area. You can upload up to 5MB')->setParam('return', 'file-uri')->setLabel('Attachments');
     /** @var $file FileUpload*/
     $file = $form->get($this->fileName);
     /** @var ModuleOptions $options */
     $size = $options->getAttachmentsMaxSize();
     $type = $options->getAttachmentsMimeType();
     $count = $options->getAttachmentsCount();
     $file->setMaxSize($size);
     if ($type) {
         $file->setAllowedTypes($type);
     }
     $file->setMaxFileCount($count);
     // pass form to element. Needed for file count validation
     // I did not find another (better) way.
     $file->setForm($form);
 }
 public function __construct($name = 'forgot-password', $options = array())
 {
     parent::__construct($name, $options);
     $this->setAttribute('data-handle-by', 'native');
     $this->setAttribute('class', 'form-horizontal');
     $this->add(array('type' => 'text', 'name' => 'identity', 'options' => array('label' => 'Username or email', 'is_disable_capable' => false)));
     $buttons = new ButtonsFieldset('buttons');
     $buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('id' => 'submit', 'type' => 'submit', 'value' => 'Reset your password', 'class' => 'btn btn-primary')));
     $this->add(array('name' => 'csrf', 'type' => 'csrf'));
     $this->add($buttons);
 }
 /**
  * configure the formular for uploading attachments
  *
  * @param Form $form
  * @param AbstractOptions $options
  */
 protected function configureForm($form, AbstractOptions $options)
 {
     if (!$options instanceof ModuleOptions) {
         throw new \InvalidArgumentException(sprintf('$options must be instance of %s', ModuleOptions::class));
     }
     $size = $options->getAttachmentsMaxSize();
     $type = $options->getAttachmentsMimeType();
     $count = $options->getAttachmentsCount();
     $form->setIsDisableCapable(false)->setIsDisableElementsCapable(false)->setIsDescriptionsEnabled(true)->setDescription('Attach images or PDF Documents to your CV. Drag&drop them, or click into the attachement area. You can upload up to %sMB', [round($size / (1024 * 1024)) > 0 ? round($size / (1024 * 1024)) : round($size / (1024 * 1024), 1)])->setParam('return', 'file-uri')->setLabel('Attachments');
     /* @var $file \Core\Form\Element\FileUpload */
     $file = $form->get($this->fileName);
     $file->setMaxSize($size);
     if ($type) {
         $file->setAllowedTypes($type);
     }
     $file->setMaxFileCount($count);
     // pass form to element. Needed for file count validation
     // I did not find another (better) way.
     $file->setForm($form);
 }
Beispiel #8
0
 /**
  * @testdox      Can be constructed in all possible states
  * @dataProvider provideAddClassData
  * @covers Core\Form\Form::addClass
  *
  * @param string $class     the expected name for the status
  * @param string $expected  the expected order for the status
  */
 public function testAddClass($classes, $expected)
 {
     if (is_array($classes)) {
         foreach ($classes as $class) {
             $this->target->addClass($class);
         }
     } elseif (is_string($classes)) {
         $this->target->addClass($classes);
     }
     $x = $this->target->getAttribute('class');
     $this->assertEquals($x, $expected);
 }
Beispiel #9
0
 public function __construct($name = 'login-form', $options = array())
 {
     parent::__construct($name, $options);
     $this->setAttribute('data-handle-by', 'native');
     $this->setAttribute('class', 'form-inline');
     $fieldset = new Fieldset('credentials');
     $fieldset->setOptions(array('renderFieldset' => true));
     $fieldset->add(array('name' => 'login', 'options' => array('id' => 'login', 'label' => 'Login name')));
     $fieldset->add(array('type' => 'password', 'name' => 'credential', 'options' => array('id' => 'credential', 'label' => 'Password')));
     $this->add($fieldset);
     $buttons = new \Core\Form\ButtonsFieldset('buttons');
     $buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('id' => 'submit', 'type' => 'submit', 'value' => 'login', 'class' => 'btn btn-primary')));
     $this->add($buttons);
 }
Beispiel #10
0
 /**
  * @param int|null|string $name
  * @param array           $options
  *
  * fieldset: string service name of the Fieldset class
  */
 public function __construct($name = null, array $options = [])
 {
     $this->fieldset = array_key_exists('fieldset', $options) ? $options['fieldset'] : self::BASE_FIELDSET;
     parent::__construct();
 }
Beispiel #11
0
 public function __construct($id)
 {
     parent::__construct($id);
 }
 public function bind($object, $flags = FormInterface::VALUES_NORMALIZED)
 {
     /** Ensure the form is build prior to binding */
     $this->setObject($object);
     return parent::bind($object);
 }
Beispiel #13
0
 public function __construct($useAcl = false)
 {
     $this->isExtended = (bool) $useAcl;
     parent::__construct();
 }
Beispiel #14
0
use SocioChat\DIBuilder;
use Core\Form\Form;
use SocioChat\Forms\Rules;
use Zend\Config\Config;
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'config.php';
$container = DI::get()->container();
DIBuilder::setupNormal($container);
$config = $container->get('config');
/* @var $config Config */
$email = isset($_REQUEST['email']) ? $_REQUEST['email'] : null;
$code = isset($_REQUEST['code']) ? $_REQUEST['code'] : null;
$validation = null;
if (!$email || !$code) {
    exit;
}
$form = new Form();
$form->import($_REQUEST);
$form->addRule(ActivationsDAO::EMAIL, Rules::email(), 'email в таком формате не может существовать.', 'emailPattern')->addRule(ActivationsDAO::EMAIL, function ($val) {
    $user = UserDAO::create()->getByEmail($val);
    return (bool) $user->getId();
}, 'Такой email не найден в системе.', 'userSearch');
$validation = $form->validate();
if (!$validation) {
    $heading = 'Ошибка!';
    $message = 'Email невалиден.';
    require_once "pages/common_page.php";
    exit;
}
$activation = ActivationsDAO::create();
$result = $activation->getActivation($email, $code);
$activation = $result[0];
Beispiel #15
0
}
if ($activation->getCode() != $code) {
    require_once "pages/activation/error.php";
    exit;
}
if (strtotime($activation->getTimestamp()) + $config->activationTTL < time()) {
    $activation->setIsUsed(true);
    $activation->save();
    require_once "pages/activation/error.php";
    exit;
}
if (!$password) {
    require_once "pages/activation/prepare.php";
    exit;
}
$form = new Form();
$form->import($_REQUEST);
$form->addRule('password', Rules::password(), 'Пароль должен быть от 8 до 20 символов')->addRule('password-repeat', Rules::password(), 'Пароль должен быть от 8 до 20 символов');
$validation = $form->validate();
if (!$validation) {
    require_once "pages/activation/prepare.php";
    exit;
}
if ($password != $passwordRepeat) {
    $validation = false;
    $form->markWrong('password', 'Введенные пароли не совпадают');
    require_once "pages/activation/prepare.php";
    exit;
}
$user = UserDAO::create()->getByEmail($email);
$user->setPassword(password_hash($password, PASSWORD_BCRYPT));
 public function __construct($extended = false)
 {
     $this->isExtended = (bool) $extended;
     parent::__construct();
 }
 public function setObject($object)
 {
     $this->get('base')->setObject($object);
     return parent::setObject($object);
 }
 /**
  * @param CoreForm $form
  * @param string $key
  */
 protected function setupForm(CoreForm $form, $key)
 {
     $form->setAttribute('action', sprintf('?form=%s', $this->formatAction($key)))->setAttribute('data-entry-key', $key)->setOption('control_buttons', [['class' => 'btn-danger form-collection-container-remove-button', 'icon' => 'delete-o', 'label' => 'Remove']]);
 }