Skip to content

Commit

Permalink
add default domain when adding a new translation
Browse files Browse the repository at this point in the history
  • Loading branch information
Seb authored and sdieunidou committed Sep 13, 2017
1 parent 4a280b2 commit 89609e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Controller/TranslationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Lexik\Bundle\TranslationBundle\Controller;

use Lexik\Bundle\TranslationBundle\Form\Type\TransUnitType;
use Lexik\Bundle\TranslationBundle\Storage\StorageInterface;
use Lexik\Bundle\TranslationBundle\Util\Csrf\CsrfCheckerTrait;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
Expand Down Expand Up @@ -89,7 +90,7 @@ public function newAction(Request $request)
{
$handler = $this->get('lexik_translation.form.handler.trans_unit');

$form = $this->createForm('Lexik\Bundle\TranslationBundle\Form\Type\TransUnitType', $handler->createFormData(), $handler->getFormOptions());
$form = $this->createForm(TransUnitType::class, $handler->createFormData(), $handler->getFormOptions());

if ($handler->process($form, $request)) {
$message = $this->get('translator')->trans('translations.successfully_added', array(), 'LexikTranslationBundle');
Expand Down
8 changes: 6 additions & 2 deletions Form/Type/TransUnitType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
));
$builder->add('domain', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
'label' => 'translations.domain',
'choices' => array_combine($options['domains'], $options['domains']),
'choices' => array_merge(
array_combine($options['default_domain'], $options['default_domain']),
array_combine($options['domains'], $options['domains'])
),
));
$builder->add('translations', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array(
'entry_type' => 'Lexik\Bundle\TranslationBundle\Form\Type\TranslationType',
Expand All @@ -48,7 +51,8 @@ public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => null,
'domains' => array('messages'),
'default_domain' => ['messages'],
'domains' => [],
'translation_class' => null,
'translation_domain' => 'LexikTranslationBundle',
));
Expand Down

0 comments on commit 89609e4

Please sign in to comment.