Displaying ActivtyReason & ActivityType into activity creation form

This commit is contained in:
Marc Ducobu 2015-07-03 10:15:50 +02:00
parent a0798c014e
commit 9c565063af
4 changed files with 149 additions and 3 deletions

View File

@ -81,9 +81,9 @@ class ActivityType extends AbstractType
)
))
->add('user')
//->add('scope')
//->add('reason')
//->add('type')
->add('scope')
->add('reason', 'translatable_activity_reason')
->add('type', 'translatable_activity_type')
//->add('person')
;

View File

@ -0,0 +1,66 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@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\ActivityBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Description of TranslatableActivityReason
*
* @author Champs-Libres Coop
*/
class TranslatableActivityReason extends AbstractType
{
/**
* @var RequestStack
*/
private $requestStack;
public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}
public function getName()
{
return 'translatable_activity_reason';
}
public function getParent()
{
return 'entity';
}
public function configureOptions(OptionsResolver $resolver)
{
$locale = $this->requestStack->getCurrentRequest()->getLocale();
$resolver->setDefaults(
array(
'class' => 'ChillActivityBundle:ActivityReason',
'property' => 'name['.$locale.']'
)
);
}
}

View File

@ -0,0 +1,66 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@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\ActivityBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Description of TranslatableActivityType
*
* @author Champs-Libres Coop
*/
class TranslatableActivityType extends AbstractType
{
/**
* @var RequestStack
*/
private $requestStack;
public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}
public function getName()
{
return 'translatable_activity_type';
}
public function getParent()
{
return 'entity';
}
public function configureOptions(OptionsResolver $resolver)
{
$locale = $this->requestStack->getCurrentRequest()->getLocale();
$resolver->setDefaults(
array(
'class' => 'ChillActivityBundle:ActivityType',
'property' => 'name['.$locale.']'
)
);
}
}

View File

@ -6,6 +6,20 @@ services:
tags:
- { name: form.type, alias: translatable_activity_reason_category }
chill.activity.form.type.translatableactivityreason:
class: Chill\ActivityBundle\Form\Type\TranslatableActivityReason
arguments:
- "@request_stack"
tags:
- { name: form.type, alias: translatable_activity_reason }
chill.activity.form.type.translatableactivitytype:
class: Chill\ActivityBundle\Form\Type\TranslatableActivityType
arguments:
- "@request_stack"
tags:
- { name: form.type, alias: translatable_activity_type }
chill.activity.form.type.activity:
class: Chill\ActivityBundle\Form\ActivityType
arguments: