2017 © Pedro Peláez
 

library symfony-form-array-to-delimited-string-transformer

Data transformer for SF form. Transforms delimited to string to array and vice-versa

image

dantleech/symfony-form-array-to-delimited-string-transformer

Data transformer for SF form. Transforms delimited to string to array and vice-versa

  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 5 Forks
  • 3 Open issues
  • 2 Versions
  • 2 % Grown

The README.md

Array to delimited string data transformer

Build Status, (*1)

This is a data transformer for the Symfony form framework., (*2)

It is meant for transforming text fields containing delimited strings to arrays., (*3)

Usage

You can use the data transformer as follows:, (*4)

$form->add(
    $builder->create('tags', 'text')->addModelTransformer(
        new ArrayToDelimitedStringTransformer()
    )
);

This will transform the tags text field as follows:, (*5)

// Tranform
array('one', 'two', 'three', 'four') === 'one, two, three, four'

// Reverse transform
'   one ,  two    , three, four,' === array('one', 'two', 'three', 'four')

Changing the delimiter

You can change the delimiting string with the first constructor argument:, (*6)

new ArrayToDelimitedStringTransformer(';')

Will result in:, (*7)

// Transform
array('one', 'two', 'three', 'four') === 'one; two; three; four'

// Reverse Transform
'one   ; two;three ;     four' => array('one', 'two', 'three')

Output padding

Additionally you can change the way in which the output is formatted with by setting the amount of whitespace (padding) before and after the text elements produced by a transformation:, (*8)

new ArrayToDelimitedStringTransformer('%', 1, 1)

Will result in:, (*9)

// Transform
array('one', 'two', 'three', 'four') === 'one % two % three % four'

// Reverse Transform
'one   % two%three %     four' => array('one', 'two', 'three')

The Versions

23/05 2017

dev-master

9999999-dev

Data transformer for SF form. Transforms delimited to string to array and vice-versa

  Sources   Download

MIT

The Requires

 

11/10 2014

0.1

0.1.0.0

Data transformer for SF form. Transforms delimited to string to array and vice-versa

  Sources   Download

MIT

The Requires