Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Chill-project
Chill-Main
Commits
7b7cdeba
Commit
7b7cdeba
authored
Nov 13, 2014
by
Julien Fastré
Browse files
create type select2_choice and apply select2 only on those fields
parent
3e8843dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Form/Type/Select2ChoiceType.php
0 → 100644
View file @
7b7cdeba
<?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
Select2ChoiceType
extends
AbstractType
{
public
function
getName
()
{
return
'select2_choice'
;
}
public
function
getParent
()
{
return
'choice'
;
}
public
function
setDefaultOptions
(
OptionsResolverInterface
$resolver
)
{
$resolver
->
replaceDefaults
(
array
(
'attr'
=>
array
(
'class'
=>
'select2 '
))
);
}
}
Resources/config/services.yml
View file @
7b7cdeba
...
...
@@ -25,3 +25,8 @@ services:
-
"
%locale%"
tags
:
-
{
name
:
form.type
,
alias
:
translatable_string
}
chill.main.form.type.select2choice
:
class
:
Chill\MainBundle\Form\Type\Select2ChoiceType
tags
:
-
{
name
:
form.type
,
alias
:
select2_choice
}
Resources/views/layout.html.twig
View file @
7b7cdeba
...
...
@@ -134,7 +134,7 @@
}
});
$
(
'
select
'
).
select2
();
$
(
'
.
select
2
'
).
select2
();
</script>
</body>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment