Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Symfony Form Array To Delimited String Transformer Laravel Package

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

Symfony Form data transformer that converts delimited text fields to arrays and back. Trims whitespace, ignores empty values, and supports custom delimiters plus configurable output padding for formatted tag/keyword input.

View on GitHub
Deep Wiki
Context7

Array to delimited string data transformer

Build Status

This is a data transformer for the Symfony form framework.

It is meant for transforming text fields containing delimited strings to arrays.

Usage

You can use the data transformer as follows:

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

This will transform the tags text field as follows:

// 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:

new ArrayToDelimitedStringTransformer(';')

Will result in:

// 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:

new ArrayToDelimitedStringTransformer('%', 1, 1)

Will result in:

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

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

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime