Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6750 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

<?php

declare(strict_types=1);

namespace LeadersLinked\Form\Auth;

use Laminas\Form\Form;
use LeadersLinked\Model\UserType;
use LeadersLinked\Model\User;

class SignupForm extends Form
{
    /**
     * 
     * @param array $config
     */
    public function __construct($config) 
    {

        parent::__construct();
        $this->setInputFilter(new SignupFilter());
        
        $this->add([
            'name' => 'first_name',
            'type' => \Laminas\Form\Element\Text::class,
             'attributes' => [
                'maxlength'     => 64,
                'id'                    => 'first_name',
            ]
         ]);
         $this->add([
            'name' => 'last_name',
            'type' => \Laminas\Form\Element\Text::class,
            'attributes' => [
                'maxlength'     => 64,
                'id'                    => 'last_name',
            ]
        ]);
         $this->add([
            'name' => 'email',
            'type' => \Laminas\Form\Element\Text::class,
            'attributes' => [
                'maxlength'     => 64,
                'id'                    => 'email',
            ]
        ]);
         $this->add([
             'name' => 'password',
             'type' => \Laminas\Form\Element\Text::class,
             'attributes' => [
                 'maxlength'    => 16,
                 'id'                   => 'password',
             ]
         ]);
         $this->add([
             'name' => 'confirmation',
             'type' => \Laminas\Form\Element\Text::class,
             'attributes' => [
                 'maxlength'    => 16,
                 'id'                   => 'confirmation',
             ]
         ]);

        $this->add([
            'name' => 'terms_and_conditions',
            'type' => \Laminas\Form\Element\Checkbox::class,
            'attributes' => [
                'id' => 'terms_and_conditions',
            ],
            'options' => [
                'use_hidden_element' => false,
                'unchecked_value' => '0',
                'checked_value' => '1',
            ]
        ]);
        
        
        $this->add([
            'name' => 'terms_and_conditions',
            'type' => \Laminas\Form\Element\Checkbox::class,
            'attributes' => [
                'id' => 'terms_and_conditions',
            ],
            'options' => [
                'use_hidden_element' => false,
                'unchecked_value' => '0',
                'checked_value' => '1',
            ]
        ]);
        
        $this->add([
            'name' => 'is_adult',
            'type' => \Laminas\Form\Element\Checkbox::class,
            'attributes' => [
                'id' => 'is_adult',
            ],
            'options' => [
                'use_hidden_element' => false,
                'unchecked_value' => User::IS_ADULT_NO,
                'checked_value' => User::IS_ADULT_YES,
            ]
        ]);
        
        if($config['leaderslinked.runmode.sandbox']) {
            $site_key      = $config['leaderslinked.google_captcha.sandbox_site_key'];
            $secret_key    = $config['leaderslinked.google_captcha.sandbox_secret_key'];
        } else {
            $site_key      = $config['leaderslinked.google_captcha.production_site_key'];
            $secret_key    = $config['leaderslinked.google_captcha.production_secret_key'];
        }
        
        $curl = new \Laminas\Http\Client\Adapter\Curl();
        $curl = $curl->setCurlOption(CURLOPT_SSL_VERIFYHOST,false);
        $curl = $curl->setCurlOption(CURLOPT_SSL_VERIFYPEER,false);
        
        $httpClient = new \Laminas\Http\Client();
        $httpClient->setAdapter($curl);
        
        
        $captcha = new \Laminas\Captcha\ReCaptcha();
        $captcha->setService(new \Laminas\ReCaptcha\ReCaptcha($site_key, $secret_key, $params = null, $options = ['callback' => 'enableBtn'], $ip = null, $httpClient));
        
        
        // Add the CAPTCHA field
        $this->add([
            'type' => 'captcha',
            'name' => 'captcha',
            'attributes' => [
                'data-role' => 'none',
            ],
            'options' => [
                'captcha' => $captcha,
            ],
        ]);
    }

      
}