PHP code example of bic / form-validation

1. Go to this page and download the library: Download bic/form-validation library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bic / form-validation example snippets


//...
new Bic\FormValidationBundle\BicFormValidationBundle()
//...

        // form Data models
        $formData = array(
            new Form\Model\Register(),
            new Form\Model\Document()
        );

        // form builder
        $formBuilder = $this->container
                ->get('form.factory')
                ->createNamedBuilder('form', 'form', $formData)
                ->add('phone', 'text')
                ->add('password', 'password')
                ->add('document', new Form\Type\DocumentType())
                ->add('submit', 'submit');

        // get form from form builder
        // (http://www.interesarte.com/wp-content/uploads/2013/05/willsmith.jpg)
        $form = $formBuilder
                ->getForm()
                ->handleRequest($request);

        $formValidation = $this->get('bic_form_validation.form_validation');
        //returns FormValidation object
        $formValidation->extractValidation($form);
        //returns fields array
        $formValidation->getFields();
        //returns json object
        $formJson = $formValidation->toJson();

        return array(
            //...
            'form_validation' => $formJson,
            //...
        );