1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- /*
- * This file is part of the Sonata package.
- *
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace Sonata\AdminBundle\Form\Extension;
- use Symfony\Component\Form\AbstractTypeExtension;
- use Symfony\Component\Form\FormView;
- use Symfony\Component\Form\FormInterface;
- use Symfony\Component\OptionsResolver\OptionsResolverInterface;
- /**
- * Class ChoiceTypeExtension
- *
- * @package Sonata\AdminBundle\Form\Extension
- *
- * @author Amine Zaghdoudi <amine.zaghdoudi@ekino.com>
- */
- class ChoiceTypeExtension extends AbstractTypeExtension
- {
- /**
- * {@inheritdoc}
- */
- public function setDefaultOptions(OptionsResolverInterface $resolver)
- {
- $resolver->setOptional(array('sortable'));
- }
- /**
- * {@inheritdoc}
- */
- public function buildView(FormView $view, FormInterface $form, array $options)
- {
- $view->vars['sortable'] = array_key_exists('sortable', $options) && $options['sortable'];
- }
- /**
- * Returns the name of the type being extended.
- *
- * @return string The name of the type being extended
- */
- public function getExtendedType()
- {
- return 'choice';
- }
- }
|