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
79ccfb18
Commit
79ccfb18
authored
Nov 26, 2014
by
Marc Ducobu
Browse files
Form type for Languages (select2)
parent
22df3cb1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Form/Type/Select2LanguageType.php
0 → 100644
View file @
79ccfb18
<?php
/*
* Chill is a software for social workers
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.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
Chill\MainBundle\Templating\TranslatableStringHelper
;
use
Symfony\Component\OptionsResolver\OptionsResolverInterface
;
use
Chill\MainBundle\Entity\Language
;
use
Symfony\Component\HttpFoundation\RequestStack
;
/**
* Extends choice to allow adding select2 library on widget for languages (multiple)
*/
class
Select2LanguageType
extends
AbstractType
{
/**
*
* @var RequestStack
*/
private
$requestStack
;
public
function
__construct
(
RequestStack
$requestStack
)
{
$this
->
requestStack
=
$requestStack
;
}
public
function
getName
()
{
return
'select2_chill_language'
;
}
public
function
getParent
()
{
return
'select2_entity'
;
}
public
function
setDefaultOptions
(
OptionsResolverInterface
$resolver
)
{
$locale
=
$this
->
requestStack
->
getCurrentRequest
()
->
getLocale
();
$resolver
->
setDefaults
(
array
(
'class'
=>
'Chill\MainBundle\Entity\Language'
,
'property'
=>
'name['
.
$locale
.
']'
));
}
}
\ No newline at end of file
Resources/config/services.yml
View file @
79ccfb18
...
...
@@ -54,7 +54,13 @@ services:
-
"
@request_stack"
tags
:
-
{
name
:
form.type
,
alias
:
select2_chill_country
}
chill.main.form.type.select2language
:
class
:
Chill\MainBundle\Form\Type\Select2LanguageType
arguments
:
-
"
@request_stack"
tags
:
-
{
name
:
form.type
,
alias
:
select2_chill_language
}
chill.main.search_provider
:
class
:
Chill\MainBundle\Search\SearchProvider
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