Download the PHP package lin3s/wp-symfony-form without Composer
On this page you can find all versions of the php package lin3s/wp-symfony-form. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lin3s/wp-symfony-form
More information about lin3s/wp-symfony-form
Files in lin3s/wp-symfony-form
Package wp-symfony-form
Short Description WordPress plugin to allow using Symfony form component with ease
License MIT
Homepage http://lin3s.com
Informations about the package wp-symfony-form
WP Symfony Form
WordPress plugin to allow using Symfony form component with ease
Installation
If you are using composer run the following command:
If your composer.json
is properly set up you should find this package in plugins folder
Usage
First of all, enable this plugin in the WordPress admin panel.
To create your first form extend as usual from the AbstractType
class provided by Symfony component.
To enable the Ajax calls for this form you need to subscribe to the wp_symfony_form_wrappers
WordPress hook.
Rendering the form
In case you want to use Twig for rendering a Bridge is provided, just run the following code line passing Twig instance
component/form.twig
is your custom form theme that will be used to render the forms. Check the docs about form customization for further info.
Timber
In case you are using Timber you should use twig_apply_filters
hook.
Also, you have to load the form base views inside Timber global locations variable:
Important Submit event is binded to every element with .form
class. In case you need to change it just do the following:
Also error container for each form item can be changed using WPSymfonyForm.formErrorsSelector
.
The FormWrapper
The FormWrapper
is a class designed to contain a form and all its related actions. As you've seen above a new instance is
created for each form you want to use in your WordPress project, and need to be registered inside the
FormWrapperRegistry
.
As first parameter it receives the fully qualified namespace and as second parameter it receives an array of classes
implementing Action
interface.
Actions on success
In case you need to perform any server side actions, it's as easy as to implement execute
method of Action
interface.
A form instance will to be used as desired. Check src/Action
folder to check already implemented actions.
To bind this action to a specific form you need to add it in the FormWrapper
.
For client side success actions you can add your callback using the global WPSymfonyForm
namespace as follows:
onSuccess()
andonError()
are available to hook into the form.
All versions of wp-symfony-form with dependencies
symfony/config Version ^2.3 || ^3.0
symfony/finder Version ^2.3 || ^3.0
symfony/form Version ^2.8 || ^3.0
symfony/translation Version ^2.3 || ^3.0
symfony/twig-bridge Version ^2.3 || ^3.0
symfony/validator Version ^2.3 || ^3.0