Developed with love by KnpLabs Hire us for your project!
0

IoFormBundle

by ioalessio

a set of form types for symfony2 using jquery/ui, datepicker, slider, autocomplete/combobox Entity and more..

This bundle is no more developed, you can use this bundle for same functionality
http://github.com/genemu/GenemuFormBundle

A set of Form Types for symfony2 framework using JQuery

How to Install

  1. Add this bundle to your vendor/ dir
    • Vendor Mode Add the following lines in your deps file::
[IoFormBundle]
  git=git://github.com/ioalessio/IoFormBundle.git
  target=/bundles/Io/FormBundle

Run the vendor script:

./bin/vendors install
  • Submodule Mode
$ git submodule add git://github.com/ioalessio/IoFormBundle.git vendor/bundles/Io/FormBundle
  1. Add the "Io" namespace to your autoloader:
<?php
// app/autoload.php
$loader->registerNamespaces(array(
    'Io' => __DIR__.'/../vendor/bundles',
// your other namespaces
));
  1. Add the "Io" namespace to your autoloader:
<?php
        // app/ApplicationKernel.php
        public function registerBundles()
        {
            return array(
                // ...
                new Io\FormBundle\IoFormBundle(),
                // ...
            );
        }
  1. Add the twig form configuration:
        // app/config/config.yml
        twig:
            form:
                resources:
                    - 'IoFormBundle:Form:fields.html.twig'

        io_form:
            jquery_tinymce:
              source: /bundles/yourbundle/js/tiny_mce/tiny_mce.js
              theme:  simple

How to use Form Type

Build your form:

<?php
    public function buildForm(FormBuilder $builder, array $options)
    {
        $builder
            ->add('user', 'jquery_entity_combobox', array('class' => 'Io\MyBundle\Entity\MyEntity'))
            ->add('date', 'jquery_date', array('format' => 'dd/MM/y')
            ->add('int_field', 'jquery_range', array('min' => 0, 'max' => 50, 'step' => 2)
            ->add('note', 'jquery_tinymce')
        );
    }

Several options are available on jquery_date widget

 <?php
 $builder->add('the_date', 'jquery_date', array(
  'format' => 'dd/MM/y'  'dd.MM.yy' 'd MMM, y'
  'changeMonth'=> 'true',
  'changeYear' => true,
  'minDate'=> '-1y',
  'maxDate'=> '+1y',
  'yearRange' => '-1y:+1y',
  'showOn' => 'focus'
));

In addition, non-supported datepicker options can be added by prepending with "jqd."

<?php
 $builder->add('the_date', 'jquery_date', array(
 ...
  'jqd.appendText' => 'extra text',
  'jqd.buttonText' => 'BUTTON!'
))

Will render as:

$( "#wn_trackingbundle_resulttype_date" ).datepicker({
    ...
    appendText: 'boosh!',
    buttonText: 'BUTTON!'
});

More details on some types:

THAT'S ALL

WARNINGS:
Form Types uses last version of Jquery v1.6 and JQueryUI v1.8 Libraries
You must have jquery and jquery ui already loaded in your template
You must include jquery tinymce library (v3.4.4) in your project ( http://www.tinymce.com/download/download.php )

#yourlayout.html.twig
<body>
  ...
  {% block js %}
  <script type="text/javascript" src="{{ asset('path/js/jquery-ui-1.8.15.custom.min.js') }}"></script>
  <script type="text/javascript" src="{{ asset('path/js/js/combobox.js') }}"></script>
  <script type="text/javascript" src="{{ asset('path/js/js/tiny_mce/jquery.tinymce.js') }}"></script>
  {% endblock %}
</body>
Copyright (c) 2011 Alessio Baglio

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
io_form:
jquery_tinymce:
source:
theme: simple