fix bugs in accompanying periods

ref #11
This commit is contained in:
2016-05-17 10:02:45 +02:00
parent 8b98e8a4b6
commit ce7c149c35
12 changed files with 355 additions and 77 deletions

View File

@@ -7,6 +7,8 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
class AccompanyingPeriodType extends AbstractType
{
@@ -38,6 +40,8 @@ class AccompanyingPeriodType extends AbstractType
//if the period_action is "close, should not be shown"
($options['period_action'] === 'close')
OR
($options['period_action'] === 'create')
OR
($options['period_action'] === 'update' AND !$accompanyingPeriod->isOpen())
) {
$form->add('closingDate', 'date', array('required' => true,
@@ -65,7 +69,12 @@ class AccompanyingPeriodType extends AbstractType
->setRequired(array('period_action'))
->addAllowedTypes(array('period_action' => 'string'))
->addAllowedValues(array('period_action' => array(
'update', 'open', 'close')));
'update', 'open', 'close', 'create')));
}
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['action'] = $options['period_action'];
}
/**