PHP code example of tentwofour / sf2-form

1. Go to this page and download the library: Download tentwofour/sf2-form 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/ */

    

tentwofour / sf2-form example snippets


$pn = '+111234567890';
$f = new PhoneNumberViewTransformer();
$formatted = $f->transform($pn);
echo $formatted;
// Outputs: '+11 (123) 456-7890'

$pn = '+(11) 123-456-7890';
$f = new PhoneNumberViewTransformer();
$formatted = $f->reverseTransform($pn);
echo $formatted;
// Outputs: '+111234567890';


// src/AppBundle/Form/ProfileType.php

use Symfony\Component\Form\AbstractType;
use Ten24\Component\Form\Extension\DataTransformer;

class ProfileType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder,
                              array $options)
    {
        $transformer = new PhoneNumberViewTransformer();
        // Optionally change the display format, see PhoneNumberFormatter for all possible values
        // $transformer->setDisplayFormat(PhoneNumberFormtter::FORMAT_DOTTED)

        $builder->add($builder
                              ->create('phoneNumber1',
                                       null,
                                       [
                                           '

$postalCode = 'S4p0H0';
$formatter = new PostalCodeViewTransformer();
$formatted = $formatter->transform($postalCode);
echo $formatted;
// Outputs: 'S4P 0H0'

$postalCode = 'S4p 0H0 ';
$formatter = new PostalCodeViewTransformer();
$formatted = $formatter->reverseTransform($postalCode);
echo $formatted;
// Outputs: 'S4P0H0'


// src/AppBundle/Form/ProfileType.php

use Symfony\Component\Form\AbstractType;
use Ten24\Component\Form\Extension\DataTransformer;

class ProfileType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder,
                              array $options)
    {
        $transformer = new PostalCodeViewTransformer();

        $builder->add($builder
                              ->create('postalCode',
                                       null,
                                       [
                                           '