2017 © Pedro Peláez
 

library symfony-type-extras-bundle

Extra Symfony Form Input Types

image

smada/symfony-type-extras-bundle

Extra Symfony Form Input Types

  • Thursday, May 28, 2015
  • by smadaman
  • Repository
  • 1 Watchers
  • 0 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Smada SymfonyTypeExtrasBundle

This bundle includes additional Field Types for Symfony Forms. they include: - "input_boxes" form field type. This input is great for account numbers, abns etc where you want 1 input box per number but the transformer returns the value as a string so it is easy to deal with., (*1)

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest version of this bundle: NOTE: This version is not entirely stable yet, (*2)

$ composer require smada/symfony-type-extras-bundle "dev-master"

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*3)

Step 2: Enable the Bundle

Then, enable the bundle by adding the following line in the app/AppKernel.php file of your project:, (*4)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Smada\SymfonyTypeExtrasBundle\SmadaSymfonyTypeExtrasBundle(),
        );

        // ...
    }

    // ...
}

Step 3: Add in the field template

Add in the template so the field knows how to be rendered. You can override this with your own rendering template by adding your own class and changing the value of this setting, (*5)

# app/config/config.yml
twig:
    form:
        resources:
            - SmadaSymfonyTypeExtrasBundle:Form:fields.html.twig

Step 4: Add Resource Assets

Add in the css and js as assets in your assetic config., (*6)

# app/config/config.yml
assetic:
    use_controller: false
    assets:
        smada_types_css:
            inputs:
                - '@SmadaSymfonyTypeExtrasBundle/Resources/public/css/input-boxes.css'
        smada_types_js:
            inputs:
                - '@SmadaSymfonyTypeExtrasBundle/Resources/public/js/input-boxes.js'

Step 5: Reference Assets

  • Now you will need to reference it in your layout
{% stylesheets '@smada_types_css' %}
    <link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}

{% javascripts '@smada_types_js' %}
    
{% endjavascripts %}
  • Now dump your assetic
$ php app/console assetic:dump

Examples

  • Input Boxes
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder->add('accountNumber', 'input_boxes', ['boxes' => 10])
}

The Versions

28/05 2015

dev-master

9999999-dev

Extra Symfony Form Input Types

  Sources   Download

28/05 2015

1.0

1.0.0.0

Extra Symfony Form Input Types

  Sources   Download