1. Go to this page and download the library: Download trt/formable 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/ */
trt / formable example snippets
use Formable\Definition\Formable;
use Symfony\Component\Validator\Constraints as Assert;
class PublishPostCommand
{
/**
* @Formable(name="title", dataType="text")
*
* @Assert\Length(max=250)
*/
public $title;
/**
* @Formable(name="content", dataType="text")
*/
public $content;
/**
* @Formable(name="tags", dataType="collection", options={
* "type"="text",
* "allow_add"=true
* })
*
* @Assert\Count(
* min = "2"
* )
*
*/
public $tags;
/**
* @Formable(name="date", dataType="date", options={
* "widget"="single_text",
* "format"="yyyy-M-d"
* })
*/
public $date;
}
/**
* @var
*
* @Formable(name="moneyDTO", class="Formable\Tests\Integration\DTOs\TestMoneyDTO")
*/
public $moneyDTO;
public function publishAction(Request $request)
{
$publishCommand = new PublishPostCommand();
$publishCommand->date = new \DateTime('now');
$form = $this->get('trt.formable')->generate($publishCommand);
$form->submit($request->request->all(), false /* Do not clear missing data */);
if ($form->isValid()) {
...
}
}
// Register the Bundle
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
...
new \Formable\Bundle\FormableBundle(),
);
return $bundles;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.