mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Create a type select2_entity and select2_chill_country refs #318
select2_entity inherits from entity with a class ".select2". select2_chill_country inherit from select2_entity [ci skip]
This commit is contained in:
parent
8fa4437b1b
commit
2485f37f93
49
Form/Type/Select2CountryType.php
Normal file
49
Form/Type/Select2CountryType.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
* Copyright (C) 2014 Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
|
||||
/**
|
||||
* Extends choice to allow adding select2 library on widget
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class Select2CountryType extends AbstractType
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'select2_chill_country';
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return 'select2_entity';
|
||||
}
|
||||
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'class' => 'Chill\MainBundle\Entity\Country'
|
||||
));
|
||||
}
|
||||
}
|
49
Form/Type/Select2EntityType.php
Normal file
49
Form/Type/Select2EntityType.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
* Copyright (C) 2014 Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
|
||||
/**
|
||||
* Extends choice to allow adding select2 library on widget
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class Select2EntityType extends AbstractType
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'select2_entity';
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return 'entity';
|
||||
}
|
||||
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver->replaceDefaults(
|
||||
array('attr' => array('class' => 'select2 '))
|
||||
);
|
||||
}
|
||||
}
|
@ -30,3 +30,13 @@ services:
|
||||
class: Chill\MainBundle\Form\Type\Select2ChoiceType
|
||||
tags:
|
||||
- {name: form.type, alias: select2_choice}
|
||||
|
||||
chill.main.form.type.select2entity:
|
||||
class: Chill\MainBundle\Form\Type\Select2EntityType
|
||||
tags:
|
||||
- {name: form.type, alias: select2_entity }
|
||||
|
||||
chill.main.form.type.select2country:
|
||||
class: Chill\MainBundle\Form\Type\Select2CountryType
|
||||
tags:
|
||||
- { name: form.type, alias: select2_chill_country }
|
||||
|
Loading…
x
Reference in New Issue
Block a user