2017 © Pedro Peláez
 

symfony-bundle subformsmadeeasy

Bundle to allow you manipulate subforms in symfony 2 easilly

image

loamok/subformsmadeeasy

Bundle to allow you manipulate subforms in symfony 2 easilly

  • Friday, February 9, 2018
  • by symio
  • Repository
  • 2 Watchers
  • 0 Stars
  • 73 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 10 Versions
  • 4 % Grown

The README.md

LoamokSubFormsMadeEasyBundle

Bundle for Symfony 2., (*1)

This Bundle allow you to manage multiple subforms with translations on the fields name the easy way., (*2)

Installation

Add it to your composer.json :

{
    "require": {
        ...,
        "loamok/subformsmadeeasy" : "dev-master"
    }
}

Update your AppKernel.php :

    public function registerBundles() {
        $bundles = array(
            ...,
            new Loamok\SubformsMadeEasyBundle\LoamokSubformsMadeEasyBundle(),
        );

Usage

This bundle require Jquery 1.11.1 or compatible., (*3)

This bundle is usable with assetic., (*4)

Make sure you're correctly configure assetic to run in your bundle :, (*5)

app/config/config.yml :, (*6)

# Assetic Configuration
assetic:
    bundles:
        ...
        - YourWonderfullBundle

Add Jquery to your layout.twig :, (*7)

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

Add the ressource to your layout.twig :, (*8)

    {% javascripts '@LoamokSubformsMadeEasyBundle/Resources/public/js/dynamicSubforms.js' %}
      <script type="text/javascript" src="{{ asset_url }}"></script>
    {% endjavascripts %}

Configure an Entity to use another entity in a multiple relation :, (*9)

<?php

namespace Your\WonderfullBundle\Entity;

use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;


/**
 * Article
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="ArticleRepository")
 * @ORM\HasLifecycleCallbacks
 */
class Article {

    /**
     * @var integer ... */
    private $id;

    /**
     * @var Collection
     *
     * @ORM\ManyToMany(targetEntity="Media", inversedBy="articles", cascade={"persist"})
     */
    private $medias;

Add subforms to the form associate :, (*10)

<?php

namespace Your\WonderfullBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class ArticleType extends AbstractType {

    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options) {
        $builder
                ->add(...)
                ->add('medias', 'collection', array(
                    'type' => new MediaType(),
                    'allow_add' => true,
                    'allow_delete' => true,
                    'by_reference' => false
                ))

Add the row in your form.html.twig :, (*11)




{{ 'admin.article.form.title' | trans }}

< div class="well"> {{ form_start(form, {'attr': {'class': 'form-horizontal'}}) }} ...
{{ form_label(form.medias, 'article.form.medias'|trans, {'label_attr': {'class': 'col-sm-3 control-label'}}) }} {{ form_errors(form.medias) }}
{{ form_widget(form.medias, {'attr': {'class': 'form-control', 'style': 'height: auto;'}}) }}

In the same twig template but at the end of the file add the js configuration :, (*12)



Samples:

Note: Samples with a relation beetween post, tags, notes), (*13)

Note: You can use translations for the labels by using "{{ 'a.trans.key' | trans }}" in place of the label, (*14)

Note: The three following samples will do exactly the same result, (*15)

Minimalistic config :, (*16)



Short config :, (*17)



Long config :, (*18)



Adding two subforms to a form :, (*19)



License

This bundle is under the GNU LESSER GENERAL PUBLIC LICENSE Version 3., (*20)

See the complete license in the bundle:, (*21)

LICENSE

The Versions

09/02 2018

dev-develop

dev-develop

Bundle to allow you manipulate subforms in symfony 2 easilly

  Sources   Download

LGPL-3.0 LGPL v3

by Huby Franck

subforms made easy bundle subforms

09/02 2018

dev-master

9999999-dev

Bundle to allow you manipulate subforms in symfony 2 easilly

  Sources   Download

LGPL-3.0 LGPL v3

by Huby Franck

subforms made easy bundle subforms

09/02 2018

1.2

1.2.0.0

Bundle to allow you manipulate subforms in symfony 2 easilly

  Sources   Download

LGPL-3.0

by Huby Franck

subforms made easy bundle subforms

22/05 2015

1.1.3

1.1.3.0

Bundle to allow you manipulate subforms in symfony 2 easilly

  Sources   Download

LGPL v3

by Huby Franck

subforms made easy bundle subforms

22/05 2015

1.1.4

1.1.4.0

Bundle to allow you manipulate subforms in symfony 2 easilly

  Sources   Download

LGPL v3

by Huby Franck

subforms made easy bundle subforms

22/05 2015

1.1.2

1.1.2.0

Bundle to allow you manipulate subforms in symfony 2 easilly

  Sources   Download

LGPL v3

by Huby Franck

subforms made easy bundle subforms

22/05 2015

1.1.1

1.1.1.0

Bundle to allow you manipulate subforms in symfony 2 easilly

  Sources   Download

LGPL v3

by Huby Franck

subforms made easy bundle subforms

21/05 2015

1.1.0

1.1.0.0

Bundle to allow you manipulate subforms in symfony 2 easilly

  Sources   Download

LGPL v3

by Huby Franck

subforms made easy bundle subforms

11/11 2014

1.0.2

1.0.2.0

Bundle to allow you manipulate subforms in symfony 2 easilly

  Sources   Download

LGPL v3

by Huby Franck

subforms made easy bundle subforms

11/11 2014

1.0.1

1.0.1.0

Bundle to allow you manipulate subforms in symfony 2 easilly

  Sources   Download

LGPL v3

by Huby Franck

subforms made easy bundle subforms