Download the PHP package a2lix/auto-form-bundle without Composer

On this page you can find all versions of the php package a2lix/auto-form-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package auto-form-bundle

A2lix AutoForm Bundle

Latest Stable Version Latest Unstable Version Total Downloads License Build Status codecov

Stop writing boilerplate form code. This bundle provides a single, powerful AutoType form type that automatically generates a complete Symfony form from any PHP class.

[!NOTE] If you need to manage form translations, please see the A2lix TranslationFormBundle, which is designed to work with this bundle.

[!TIP] A complete demonstration is also available at a2lix/demo.

Installation

Use Composer to install the bundle:

Basic Usage

The simplest way to use AutoType is directly in your controller. It will generate a form based on the properties of the entity or DTO you pass it.

How It Works

AutoType reads the properties of the class you provide in the data_class option. For each property, it intelligently configures a corresponding form field. This gives you a solid foundation that you can then customize in two main ways:

  1. Form Options: Pass a configuration array directly when you create the form.
  2. PHP Attributes: Add #[AutoTypeCustom] attributes directly to the properties of your entity or DTO.

Options passed directly to the form will always take precedence over attributes.

Customization via Form Options

This is the most flexible way to configure your form. Here is a comprehensive example:

Customization via #[AutoTypeCustom] Attribute

For a more declarative approach, you can place the configuration directly on the properties of your DTO or entity. This keeps the form configuration co-located with your data model.

Conditional Fields with Groups

You can conditionally include fields based on groups, similar to how Symfony's validation_groups work. This is useful for having different versions of a form (e.g., a "creation" version vs. an "edition" version).

To enable this, pass a children_groups option to your form. This option specifies which groups of fields should be included.

You can then assign fields to one or more groups using either form options or attributes.

Via Form Options

Use the child_groups option within the children configuration:

In this example, if children_groups is set to ['product:edit'], both name and stock will be included. If it's set to ['product:create'], only name will be included.

Via #[AutoTypeCustom] Attribute

Use the groups property on the attribute:

If no children_groups option is provided to the form, all fields are included by default, regardless of whether they have groups assigned.

Advanced Recipes

Creating a Compound Field with inherit_data

You can use a callable in the children option to create complex fields that map to the parent object, which is useful for things like date ranges.

Global Configuration

While not required, you can configure the bundle globally. For example, you can define a list of properties to always exclude.

Create a configuration file in config/packages/a2lix_auto_form.yaml:

License

This package is available under the MIT license.


All versions of auto-form-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
symfony/config Version ^7.4|^8.0
symfony/dependency-injection Version ^7.4|^8.0
symfony/form Version ^7.4|^8.0
symfony/http-kernel Version ^7.4|^8.0
symfony/property-info Version ^7.4|^8.0
symfony/type-info Version ^7.4|^8.0
phpdocumentor/reflection-docblock Version ^5.6|^6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package a2lix/auto-form-bundle contains the following files

Loading the files please wait ...