PHPackages                             tath/form\_bundle - 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. [Framework](/categories/framework)
4. /
5. tath/form\_bundle

ActiveLibrary[Framework](/categories/framework)

tath/form\_bundle
=================

Tath Form Bundle for Symfony

06PHP

Since Jan 1Pushed 9y ago1 watchersCompare

[ Source](https://github.com/TathPhp/FormBundle)[ Packagist](https://packagist.org/packages/tath/form_bundle)[ RSS](/packages/tath-form-bundle/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Tath Form Tool
==============

[](#tath-form-tool)

The Tath Form Tool makes it easy to generate Symfony Forms by adding annotations to your entities. Much in the same way that you can build a database schema using Doctrine's annotations you can also build your forms for creating and updating entities.

For an explanation of the word Tath, refer to the Tath Core README.md file.

**Tath and by extension the Tath Form Tool are under active development and the interface should not be considered stable.**

Installation
------------

[](#installation)

Since this is pre-release software I am not yet tagging version IDs. I will start using semver tags when the Grid tool is released and both are solid enough to use at least experimentally. The Form Tool requires the tath/core library, so you will either need to install it first, or set your minimum stability to dev. The easiest way to install is with:

```
composer require tath/core:master@dev
composer require tath/form_bundle:master@dev

```

Then add it to your app/AppKernel.php:

```
public function registerBundles()
{
    $bundles = [
        // ...
        new Tath\FormBundle\TathFormBundle(),
    ];
    // ...
}

```

The Form Bundle routes need to be imported into your application's routing by adding the following to your app/config/routing.yml:

```
tath_bundle:
  resource: "@TathFormBundle/Resources/config/routing.yml"
  prefix: /form

```

Of course you may prefix the Form Bundle routes with whatever you like instead of /form.

You need to create at least one template for your forms. Often you can begin with one default template, and then create customized versions if needed.

Lets say you've got a src/AppBundle/Resources/views/template.html.twig which contains a body block, and that you've created a template in src/AppBundle/Resources/views/form.html.twig that looks something like this:

```
{% extends "AppBundle::template.html.twig" %}

{% block body %}
    {{ form_start(form) }}
    {{ form_widget(form) }}
    {{ form_end(form) }}
{% endblock %}

```

You would add the following to your app/config/config.yml to make this the default template:

Usage
-----

[](#usage)

Add an @Form annotation to entities that you want to generate forms for. Add a @FormField annotation to fields that you want included in a form.

```
use Tath\FormBundle\Configuration\Form;
use Tath\FormBundle\Configuration\FormField;

/**
 * @ORM\Entity
 * @ORM\Table
 * @Form(template="AppBundle:Foo:form.html.twig", success_redirect="foos")
 */
class Foo
{
    /**
     * @ORM\Column(type="string")
     * @FormField(label="Foo Name")
     */
    private $name;
}

```

Add the @Form annotation to the class. Include an optional template, and a success redirect which is the route to return to when the form is submitted. You can optionally include a template to contain the form. If you don't use a template attribute on an entity, Tath will look in your config.yml for a default template:

```
tath_form:
  template: "AppBundle::form.html.twig"

```

If neither are provided Tath will supply its own form template which includes both the form and instructions for supplying your own.

Form fields are marked with the @FormField annotation. It can include a number of attributes, which are all optional:

### label

[](#label)

The caption to show with the input element.

### type

[](#type)

An input type. These match those built into Symfony Forms, and Tath attempts to match Doctrine types to these as best as it can. You can set the type manually to one of:

- birthday
- checkbox
- choice
- country
- currency
- date
- datetime
- email
- entity
- file
- integer
- language
- locale
- money
- number
- radio
- range
- text
- textarea
- time
- timezone
- url

### choices

[](#choices)

A list of choices for the choice type. For example:

```
/**
 * @ORM\Column(type="string")
 * @FormField(choices={"foo":"Foo", "bar":"Bar", "baz":"Baz"})
 */
private $choice;

```

### restrict

[](#restrict)

Restricts the visibility or editing of fields based on Symfony roles. For example:

```
/**
 * @ORM\Column(type="string")
 * @FormField(restrict={
 *     @RoleRestriction(visible={"ROLE_FOO"}, edit={"ROLE_BAR", "ROLE_BAZ"})
 * })
 */
private $text;

```

### min / max

[](#min--max)

Limits integers or ranges to minimum and/or maximum values.

### currency

[](#currency)

Used by the money type, indicates the expected currency for an input. See .

Twig Functions
--------------

[](#twig-functions)

These functions both include an optional 'extra' parameter which can be used to pass extra key/value pairs to the form as described in the next section.

Routes for Tath Forms can be generated with the these twig functions:

### tath\_new(class\_name, extra)

[](#tath_newclass_name-extra)

To link to a form for creating new entities, call tath\_new with the name of the entity you want to add. For example:

```
New

```

### tath\_edit(entity, extra)

[](#tath_editentity-extra)

To link to a form for editing an existing entity, call tath\_edit with the entity you wish to edit. For example:

```
Edit

```

Extra Data / Relationships
--------------------------

[](#extra-data--relationships)

Sometimes forms need to pass along extra data. For example, say you had a database that contained Artists and Albums. Albums can be managed from an Artist page. You would want to include an ID for the Artist when adding an Album, and you would want the Album's setter for the Artist to be called when creating new Albums.

Your Album entity would have a @ManyToOne relationship like so:

```
/**
 * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Artist")
 */
private $artist;

```

Links to the new album form would be generated with an extra parameter like so:

```
New Album

```

The key in the extra hash (artist) matches the name of the ManyToOne column, so Tath is able to create this relationship when the add form is submitted. Edit forms won't change the relationship so the extra parameter is not needed there as the column will be untouched.

Extra parameters are also passed back to success redirects. So, your controller that shows an artist can take an 'artist' parameter, and it will be filled from the extra hash when it is used.

###  Health Score

20

—

LowBetter than 13% 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://avatars.githubusercontent.com/u/492030?v=4)[Vic Metcalfe](/maintainers/zymsys)[@zymsys](https://github.com/zymsys)

---

Top Contributors

[![vmetcalfe](https://avatars.githubusercontent.com/u/16851882?v=4)](https://github.com/vmetcalfe "vmetcalfe (8 commits)")

### Embed Badge

![Health badge](/badges/tath-form-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tath-form-bundle/health.svg)](https://phpackages.com/packages/tath-form-bundle)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M841](/packages/laravel-socialite)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k38.6M289](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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