?? GreyFile — Mystic File Browser

Current path: home/webdevt/cryptoimpot.fr/module/Application/src/Form/ImportationForm/



?? Go up: /home/webdevt/cryptoimpot.fr/module/Application/src/Form

?? Viewing: APIForm.php

<?php

namespace Application\Form\ImportationForm;

use Laminas\Form\Element\Button;
use Laminas\Form\Element\Number;
use Laminas\Form\Element\Select;
use Laminas\Form\Element\Text;
use Laminas\Form\Form;

class APIForm extends Form {

    public function __construct($em) {

        parent::__construct('api-form');

        $this->setAttribute('method', 'post');

        $this->addElements();
        $this->addInputFilter();




        /* Csrf */
        $element = new \Laminas\Form\Element\Csrf('csrf');
        $this->add($element);

        // Submit
        $submitElement = new Button('submit');
        $submitElement
                ->setLabel('Importer')
                ->setAttributes(array(
                    'type' => 'submit',
        ));

        $this->add($submitElement, array(
            'priority' => -100,
        ));
    }

    protected function addElements() {
        // Add "email" field
        $this->add([
            'type' => 'text',
            'name' => 'public',
            'options' => [
                'label' => 'Clé d\'API',
            ],
            'attributes' => [
                'class' => 'form-control',
                'placeholder' => 'Clé'
            ],
        ]);
        $this->add([
            'type' => 'text',
            'name' => 'private',
            'options' => [
                'label' => 'Clé privée',
            ],
            'attributes' => [
                'class' => 'form-control',
                'placeholder' => 'Privée'
            ],
        ]);

        $this->add([
            'type' => 'csrf',
            'name' => 'csrf',
            'options' => [
                'csrf_options' => [
                    'timeout' => 600
                ]
            ],
        ]);

        // Add the Submit button
        $this->add([
            'type' => 'submit',
            'name' => 'submit',
            'attributes' => [
                'value' => 'Sign in',
                'id' => 'submit',
                'class' => 'btn btn-lg btn-primary btn-block'
            ],
            'options' => [
                'label' => 'Importer via API'
            ]
        ]);
    }

    private function addInputFilter() {
        // Create main input filter
        $inputFilter = $this->getInputFilter();

        // Add input for "email" field
        $inputFilter->add([
            'name' => 'public',
            'required' => true,
            'filters' => [
                ['name' => 'StringTrim'],
            ],
            'validators' => [
                [
                    'name' => 'StringLength',
                    'options' => [
                        'min' => 6,
                        'max' => 400
                    ],
                ],
            ],
        ]);
        $inputFilter->add([
            'name' => 'private',
            'required' => true,
            'filters' => [
                ['name' => 'StringTrim'],
            ],
            'validators' => [
                [
                    'name' => 'StringLength',
                    'options' => [
                        'min' => 6,
                        'max' => 400
                    ],
                ],
            ],
        ]);
    }

}


??

??