Download the PHP package ttb/form-utils without Composer

On this page you can find all versions of the php package ttb/form-utils. 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 form-utils

JJB/FormUtilsBundle

This is a clone from https://github.com/josephjbrewer/form-utils

I have made some changes to make it works with Symfony 5 and latest Twig component.

This bundle is designed to validate Symfony forms on the front-end without duplicating code or validation efforts. This plugin also fully supports translations for error messages and suggestion text.

Installation

Require composer package

Enable the bundle

Set default form theme

Edit app/config.yml and set the default form template provided by the form-utils bundle.

Usage

Assets

Add the assets provided in this bundle. I recommend using assetic.

Overriding the form theme

By default, the provided form template uses the bootstrap theme provided by Symfony. This can be easily changed by making your own form theme and extending what is provided by this bundle.

The example below uses Symfony's default form theme.

Rendering Forms

In order for the form elements to render the data attributes required for validation, you will need to use twig to render the form fields.

Data Suggestions

Data suggestions are used to provide information to the user about a form field. For example, if the form is focused on a password field, it might be helpful to show the user what characters are allowed in the password. To do this, you have to add an attribute to your form field called . This can be done in one of two ways.

With a form class

This method uses the "attr" option in the form builder.

With twig attributes

This method adds the attribute directly to the form field.

Bind validator to form

Binding the validator to the form sets up listeners on the form and all of its elements. When the blur event is triggered on a form element, the plugin will validate it. When the submit event is triggered on the form, the plugin will validate all of the form elements. If validation fails, event propagation will stop and the form will not be submitted.

In some cases, event propagation will be stopped before the validation listeners are triggered. This can happen if other javascript plugins are also listening to the submit event on the form. If this happens, you will need to manually trigger validator on your form. To do this, just use the following syntax:

Handle AJAX Errors

One of the reasons this bundle was developed is to help with binding errors that occur on the server-side to the form elements on the front-end. When validation fails on the server side, an error object is created. To handle AJAX errors on the front-end, return the serialized error object and the plugin will do the rest.

Formatting Errors & Data Suggestions

Formatting errors and data suggestions is as simple as providing an inline template. The messageTemplate key is used for errors and the suggestTemplate key is used for data suggestions.

Validator Options

Key Description Default Value
rootErrorMessage Prepend root-level error with a title? (e.g. "Your form contains errors") Only works with AJAX errors null
continueOnError Continue validation after an error occurs? false
separator Character used to concatenate form id's. _
suggestTemplate Template used for data suggestions {{message}}
messageTemplate Template used for error messages {{message}}

Advanced Usage

Supporting YAML/XML/Annotation Constraints

In a lot of cases, developers will use annotations or yaml/xml files to add constraints to a model. When a form is validated in Symfony, these constraints are validated along with any constraints added to the form.

If you instantiate a form that extends AbstractBaseForm with MetaDataConstraintService then the form will add the yaml/xml/annotation constraints to the form object when building the form view.

Create the form class

Instantiate form with metadata constraint service


All versions of form-utils with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.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 ttb/form-utils contains the following files

Loading the files please wait ....