PHPackages                             telesto/symfony-form-ensure-string - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. telesto/symfony-form-ensure-string

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

telesto/symfony-form-ensure-string
==================================

Symfony form type extension which substitutes non-string data with default value for requested form types.

07PHP

Since May 14Pushed 12y ago1 watchersCompare

[ Source](https://github.com/mdopt/TelestoSymfonyFormEnsureString)[ Packagist](https://packagist.org/packages/telesto/symfony-form-ensure-string)[ RSS](/packages/telesto-symfony-form-ensure-string/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Symfony form type extension which substitutes non-string data with default value for requested form types.

Problem:

Symfony framework by default does not protect your application from type errors in your forms.

If someone adds '\[\]' to form input name (using firebug, opera dragonfly or similar tool), the data sent to your application will be an array instead of string and (most likely) some validator will throw Symfony\\Component\\Validator\\Exception\\UnexpectedTypeException, which (if uncaught) will result in 500 Internal server error http response and 'Uncaught PHP Exception' entry log.

Example:

```
name="form_name[fieldName]" (normal input name)

name="form_name[fieldName][]" (modified input name)

```

But you probably don't want that error in your logs, and you don't want your application to send 5xx response, because it is not (semantically) a server error.

Possible solutions:

1. Use try-catch block for every `$form->submit()` to catch UnexpectedTypeException (which is dirty).
2. Wrap your form in another form that does exception catching for you and returns appropriate error. You could use a custom form factory to do that automatically.
3. Use form type extension that fixes non-string values.

This project provides solution number 3.

Usage:

```
services:

    form.type_extention.ensure_string:
        class:  Telesto\VendorExt\Symfony\Form\EnsureString\Type\FormTypeEnsureStringExtension
        arguments:
            - ['text', 'integer', 'hidden', 'number', 'percent', 'money'] # add non-standard types if you use them
        tags:
            - { name: form.type_extension, alias: form }

```

License: MIT

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2fcd5ed334ff89e048108793eb1117460219fab88051a2ab9dac7c83c51de82f?d=identicon)[mdopt](/maintainers/mdopt)

---

Top Contributors

[![mdopt](https://avatars.githubusercontent.com/u/148892?v=4)](https://github.com/mdopt "mdopt (9 commits)")

### Embed Badge

![Health badge](/badges/telesto-symfony-form-ensure-string/health.svg)

```
[![Health](https://phpackages.com/badges/telesto-symfony-form-ensure-string/health.svg)](https://phpackages.com/packages/telesto-symfony-form-ensure-string)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M105](/packages/bensampo-laravel-enum)[nette/forms

📝 Nette Forms: generating, validating and processing secure forms in PHP. Handy API, fully customizable, server &amp; client side validation and mature design.

54013.2M450](/packages/nette-forms)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
