PHP code example of ruwork / polyfill-form-dti-bundle
1. Go to this page and download the library: Download ruwork/polyfill-form-dti-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/ */
ruwork / polyfill-form-dti-bundle example snippets
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @Entity
*/
class Survey
{
/**
* @ORM\Column(type="date_immutable")
*
* @var \DateTimeImmutable
*/
private $dayOfBirth;
public function getDayOfBirth()
{
return $this->dayOfBirth;
}
public function setDayOfBirth(\DateTimeImmutable $dayOfBirth)
{
$this->dayOfBirth = $dayOfBirth;
}
}
namespace App\Controller;
use App\Entity\Survey;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\HttpFoundation\Request;
class FormController extends AbstractController
{
/**
* @Route("/form")
* @Template
*/
public function __invoke(Request $request)
{
$survey = new Survey();
$form = $this->createFormBuilder($survey)
->add('dayOfBirth', DateType::class, [
'input' => 'datetime_immutable',
])
// or let the form guesser do the job for you
->add('dayOfBirth')
->getForm()
->handleRequest($request);
return [
'form' => $form->createView(),
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.