2017 © Pedro Peláez
 

symfony-bundle polyfill-form-dti

Symfony Form polyfill adding input=datetime_immutable to date types.

image

ruwork/polyfill-form-dti

Symfony Form polyfill adding input=datetime_immutable to date types.

  • Friday, February 16, 2018
  • by RUVENTS
  • Repository
  • 3 Watchers
  • 0 Stars
  • 2,316 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 73 % Grown

The README.md

Symfony Form DateTimeImmutable Polyfill

GitHub license Travis branch Codecov branch Packagist, (*1)

This package is a polyfill for my pull request adding input=datetime_immutable option to the Symfony date and time form types., (*2)

Works with PHP >=5.5 and Symfony >=2.8., (*3)

If you use Symfony Framework have a look at the corresponding ruwork/polyfill-form-dti-bundle., (*4)

Installation

composer require ruwork/polyfill-form-dti

Usage

<?php

use Ruwork\PolyfillFormDTI\DTIExtension;
use Ruwork\PolyfillFormDTI\Guesser\DoctrineOrmDTIGuesser;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\TimeType;
use Symfony\Component\Form\Forms;

/** @var \Doctrine\Common\Persistence\ManagerRegistry $registry */

$factory = Forms::createFormFactoryBuilder()
    ->addExtension(new DTIExtension())
    // Optionally you can add a Doctrine ORM guesser
    // to guess input=datetime_immutable for Doctrine 2.6 immutable date types. 
    ->addTypeGuesser(new DoctrineOrmDTIGuesser($registry))
    ->getFormFactory();

$form = $factory
    ->createBuilder(FormType::class, [
        'datetime' => new \DateTimeImmutable('1828-09-09 12:00:00'),
        'date' => new \DateTimeImmutable('1860-01-29'),
        'time' => new \DateTimeImmutable('23:59'),
    ])
    ->add('datetime', DateTimeType::class, [
        'input' => 'datetime_immutable',
    ])
    ->add('date', DateType::class, [
        'input' => 'datetime_immutable',
    ])
    ->add('time', TimeType::class, [
        'input' => 'datetime_immutable',
    ])
    ->getForm();

Testing

vendor/bin/simple-phpunit

The Versions

16/02 2018

dev-master

9999999-dev

Symfony Form polyfill adding input=datetime_immutable to date types.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Valentin Udaltsov

form symfony polyfill

16/02 2018

0.2.1

0.2.1.0

Symfony Form polyfill adding input=datetime_immutable to date types.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Valentin Udaltsov

form symfony polyfill

11/02 2018

0.2.0

0.2.0.0

Symfony Form polyfill adding input=datetime_immutable to date types.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Valentin Udaltsov

form symfony polyfill

10/02 2018

0.1.0

0.1.0.0

Symfony Form polyfill adding input=datetime_immutable to date types.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Valentin Udaltsov

form symfony polyfill