PHPackages                             beastbytes/form-latte - 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. [Templating &amp; Views](/categories/templating)
4. /
5. beastbytes/form-latte

ActiveLibrary[Templating &amp; Views](/categories/templating)

beastbytes/form-latte
=====================

Integrates the Yii Framework Form package with view-latte Latte Template Renderer simplifying form creation

07PHP

Since Aug 10Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/beastbytes/form-latte)[ Packagist](https://packagist.org/packages/beastbytes/form-latte)[ RSS](/packages/beastbytes-form-latte/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Form Latte is a [Latte](https://latte.nette.org/) [extension](https://latte.nette.org/en/creating-extension)that integrates the Yii 3 [Form Model package](https://github.com/yiisoft/form-model) with [`view-latte`, a Latte Template View Renderer for Yii3](https://github.com/beastbytes/view-latte).

Requirements
------------

[](#requirements)

- PHP 8.1 or higher.

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

[](#installation)

Install the package using [Composer](https://getcomposer.org):

Either:

```
composer require beastbytes/form-latte
```

or add the following to the `require` section of your `composer.json`

```
"beastbytes/form-latte": "{version constraint}"
```

Configuration
-------------

[](#configuration)

To configure Latte to use the extension add it to the `extensions` key of `beastbytes/view-latte` in the params of your configuration.

```
'beastbytes/view-latte' => [
    // filters and functions
    'extensions' => [
        new BeastBytes\View\Latte\Form\FormExtension(),
    ]
],
```

Description
-----------

[](#description)

The extension adds tags to Latte for form fields (including errorSummary), and the form and fieldset HTML tags. The extension follows the conventions of the Form Model package, in that form fields are specified with the form model, field parameter, and optionally a theme; all other options are specified in the field configuration using Latte's filter syntax; where an option takes a value, the value is the same as for the equivalent form model field type.

### Form Fields

[](#form-fields)

Form field tags can have the same names as the Yii fields or HTML fields, e.g. 'text', 'email', etc.; 'tel' or 'telephone' can be used, as can 'submit' or 'submitButton', and 'reset' or 'resetButton'.

Usage
-----

[](#usage)

Write forms in Latte templates using the tags and configuration "filters" defined by the extension.

A form input has the pattern:

```
{tag $formModel, 'parameter'|config1|config2|...|configN}
```

A form button has the pattern:

```
{button |config}Content{/button}
```

A button group has the pattern:

```
{buttonGroup}
{button|attributes:[k=>v]}Button 1{/button}
{button|attributes:[k=>v]}Button 1{/button}
...
{button|attributes:[k=>v]}Button n{/button}
{/buttonGroup}
```

**NOTE:** In a buttonGroup, `attributes` is the only allowed configuration for the button tag. **Note:** The buttonGroup tag has the `encode` configuration which takes a boolean value (default `true`) to determine if button content is HTML encoded.

### Example 1

[](#example-1)

Login form

```
{form $action|csrf:$csrf}
    {email $formModel, 'email'|required|tabIndex}
    {password $formModel, 'password'|required|tabIndex}
    {submitButton}Login{/submitButton}
{/form}
```

### Example 2

[](#example-2)

A form to collect a person's name, email, address, phone number, and agreement to terms:

```
{form $action|csrf:$csrf}
    {errorSummary $formModel|onlyFirst}
    {text $formModel, 'givenName'|tabIndex}
    {text $formModel, 'familyName'|required|tabIndex}
    {email $formModel, 'email'|required|tabIndex}
    {text $formModel, 'streetAddress'|required|tabIndex}
    {text $formModel, 'locality'|required|tabIndex}
    {text $formModel, 'region'|required|tabIndex}
    {text $formModel, 'postalCode'|required|tabIndex}
    {select $formModel, 'country'|required|tabIndex|optionsData:$countries}
    {tel $formModel, 'telephone'|required|tabIndex}
    {checkbox $formModel, 'agree'|tabIndex}
    {submit}Submit{/submit}
{/form}
```

### Extra Features

[](#extra-features)

The package adds some extra features that make developing a form even easier.

- **Field enrichment**: If you use field enrichment - setting options based on validation rules, e.g. `required`, just add the `enrich` option. Yii's Field Enricher is used by default, but you can specify your own.

```
  {text $formModel, 'familyName'|enrich} {* use the default enricher *}
  {text $formModel, 'familyName'|enrich:$myEnricher} {* use $myEnricher *}
```

- **Tab Index**: If no value is given with the tabIndex option the package will auto index the fields. You can pass a value if you want to. **NOTE** do not mix auto indexing and self indexing in a form.

```
    {* Auto indexing *}
    {text $formModel, 'givenName'|tabIndex}
    {text $formModel, 'familyName'|tabIndex}
```

```
    {* Self indexing *}
    {text $formModel, 'givenName'|tabIndex:1}
    {text $formModel, 'familyName'|tabIndex:2}
```

IDE Support
-----------

[](#ide-support)

### JetBrains PhpStorm

[](#jetbrains-phpstorm)

Install the [Latte Support](https://plugins.jetbrains.com/plugin/24218-latte-support) plugin. Either copy the `latte.xml` file (in the root directory of this package) to the `.idea` directory of your project or merge with an existing `latte.xml`.

License
-------

[](#license)

The BeastBytes View Latte Form package is free software. It is released under the terms of the BSD License. Please see [`LICENSE`](./LICENSE.md) for more information.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance41

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 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/b0b5133b5137b26eeb25056449c28364ac0af31836eefba78912a9c8f0743aa3?d=identicon)[BeastBytes](/maintainers/BeastBytes)

---

Top Contributors

[![beastbytes](https://avatars.githubusercontent.com/u/1470144?v=4)](https://github.com/beastbytes "beastbytes (92 commits)")

### Embed Badge

![Health badge](/badges/beastbytes-form-latte/health.svg)

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

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)[symfony/ux-icons

Renders local and remote SVG icons in your Twig templates.

555.8M69](/packages/symfony-ux-icons)

PHPackages © 2026

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