Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4777a4c5a0
Fetching contributors…

Cannot retrieve contributors at this time

88 lines (77 sloc) 2.203 kb
<?php
/*
* This file is part of the GenemuFormBundle package.
*
* (c) Olivier Chauvel <olivier@generation-multiple.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Genemu\Bundle\FormBundle\Form\JQuery\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
/**
* ChosenType to JQueryLib
*
* @author Olivier Chauvel <olivier@generation-multiple.com>
* @author Bilal Amarni <bilal.amarni@gmail.com>
*/
class ChosenType extends AbstractType
{
private $widget;
public function __construct($widget)
{
$this->widget = $widget;
}
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['no_results_text'] = $options['no_results_text'];
$view->vars['allow_single_deselect'] = $options['allow_single_deselect'];
$view->vars['disable_search_threshold'] = $options['disable_search_threshold'];
// Adds a custom block prefix
array_splice(
$view->vars['block_prefixes'],
array_search($this->getName(), $view->vars['block_prefixes']),
0,
'genemu_jquerychosen'
);
}
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver
->setDefaults(array(
'no_results_text' => '',
'allow_single_deselect' => true,
'disable_search_threshold' => 0
))
->setNormalizers(array(
'expanded' => function (Options $options) {
return false;
}
))
;
}
/**
* {@inheritdoc}
*/
public function getParent()
{
return $this->widget;
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'genemu_jquerychosen_' . $this->widget;
}
}
Jump to Line
Something went wrong with that request. Please try again.