1. Go to this page and download the library: Download pitch/liform 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/ */
pitch / liform example snippets
$form = \Symfony\Component\Form\Forms::createFormFactory()->create();
$form->add('foo', \Symfony\Component\Form\Extension\Core\Type\TextType::class);
$form->add('bar', \Symfony\Component\Form\Extension\Core\Type\NumberType::class);
/* ... handle the request ... */
$resolver = new \Pitch\Liform\Resolver();
$resolver->setTransformer('text', new \Pitch\Liform\Transformer\StringTransformer());
$resolver->setTransformer('number', new \Pitch\Liform\Transformer\NumberTransformer());
/* ... */
$liform = new \Pitch\Liform\Liform($resolver);
$liform->addExtension(new \Pitch\Liform\Extension\ValueExtension());
$liform->addExtension(new \Pitch\Liform\Extension\LabelExtension());
/* ... */
return $liform->transform($form->createView());
namespace App\Controller;
/* use statements */
class MyFormController extends Symfony\Bundle\FrameworkBundle\Controller\AbstractController
{
protected LiformInterface $liform;
/* Let the service container inject the service */
public function __construct(LiformInterface $liform)
{
$this->liform = $liform;
}
public function __invoke(Request $request)
{
$form = $this->createForm(MyFormType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
/* ... do something ... */
} else {
return new Response($this->render('my_form.html.twig', [
'liform' => $this->liform->transform($form->createView()),
]), $form->isSubmitted() ? 400 : 200);
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.