PHP code example of limenius / liform-bundle

1. Go to this page and download the library: Download limenius/liform-bundle 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/ */

    

limenius / liform-bundle example snippets


// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Limenius\LiformBundle\LimeniusLiformBundle(),
        );

        // ...
    }

    // ...
}

        $form = $this->createForm(CarType::class, $car, ['csrf_protection' => false]);
        $schema = json_encode($this->get('liform')->transform($form));



use Limenius\Liform\Transformer\ExtensionInterface;
use Symfony\Component\Form\FormInterface;

class FormDataExtension implements ExtensionInterface
{
    /**
     * @param FormInterface $form
     * @param array         $schema
     *
     * @return array
     */
    public function apply(FormInterface $form, array $schema)
    {
        if (!$form->isRoot()) {
            return $schema;
        }

        if (!$form->getConfig()->hasOption('action')) {
            return $schema;
        }

        $schema['submit_url'] = $form->getConfig()->getOption('action');

        return $schema;
    }
}

$serializer = $this->get('serializer');
$initialValues = $serializer->normalize($form);

$serializer = $this->get('serializer');
$errors = $serializer->normalize($form);