Skip to content

Symfony2 form extensions for Admingenerator project (also working standalone!)

License

Notifications You must be signed in to change notification settings

montabou/FormExtensionsBundle

 
 

Repository files navigation

FormExtensions knpbundles.com

Latest Stable Version Total Downloads

Symfony2 form extensions for Admingenerator project inspired by genemu/GenemuFormBundle.

Documentation

For a full list of form types and extensions (and related notes) see documentation.


Installation

Add this to your composer.json:

"require": {
    "symfony2admingenerator/form-extensions-bundle": "^2.0"
}

For Symfony version lower than 2.7 or Twig lower than 1.12 add the following to your composer.json:

"require": {
    "symfony2admingenerator/form-extensions-bundle": "v2.0-beta.21"
}

And then enable the bundle in your AppKernel.php:

<?php
// AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Admingenerator\FormBundle\AdmingeneratorFormBundle(),
        new Admingenerator\FormExtensionsBundle\AdmingeneratorFormExtensionsBundle(),
        // AdmingeneratorGeneratorBundle is optional, however if you're useing it
        // make sure it is loaded AFTER AdmingeneratorFormExtensionsBundle
        new Admingenerator\GeneratorBundle\AdmingeneratorGeneratorBundle(),
    );
}
?>

To make symfony2admingenerator/form-extensions-bundle forms work, you need to edit your base template, and include static and dynamic stylesheets and javascripts.

For Admingenerator users:

{% extends 'AdmingeneratorGeneratorBundle::base_admin.html.twig' %}

{% block stylesheets %}
    {{ parent() }}

    {% include 'AdmingeneratorFormExtensionsBundle::stylesheets.html.twig' %}
    {% if form is defined and form is not empty %}
        {{ form_css(form) }}
    {% endif %}
{% endblock %}

{% block javascripts %}
    {{ parent() }}

    {% include 'AdmingeneratorFormExtensionsBundle::javascripts.html.twig' %}
    {% if form is defined and form is not empty %}
        {{ form_js(form) }}
    {% endif %}
{% endblock %}

For others:

{% block stylesheets %}
    {% include 'AdmingeneratorFormExtensionsBundle::stylesheets.html.twig' %}
    
    {% if form is defined and form is not empty %}
        {{ form_css(form) }}
    {% endif %}
{% endblock %}

{% block javascripts %}
    {% include 'AdmingeneratorFormExtensionsBundle::javascripts.html.twig' %}
    
    {% if form is defined and form is not empty %}
        {{ form_js(form) }}
    {% endif %}
{% endblock %}

Configure assetic packages (only if you use base.html.twig template)

Symfony <2.7:

framework:
    templating:
        packages:
            formextensions_css:
                version: 1.0
                version_format: "%%1$s?v%%2$s"
            formextensions_js:
                version: 1.0
                version_format: "%%1$s?v%%2$s"

Symfony 2.7 or higher:

framework:
    assets:
        packages:
            formextensions_css:
                version: 1.0
                version_format: "%%1$s?v%%2$s"
            formextensions_js:
                version: 1.0
                version_format: "%%1$s?v%%2$s"

Translators needed!

We need your support to translate forms messages :) If you want to help open a pull request and submit a package for your language.

License

For license information read carefully LICENSE file.

About

Symfony2 form extensions for Admingenerator project (also working standalone!)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 59.1%
  • PHP 20.0%
  • HTML 12.8%
  • CSS 8.1%