Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/Form/Type/FieldType/DateFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,25 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\RequestStack;

/**
* Form Type representing ezdate field type.
*/
class DateFieldType extends AbstractType
{
private const EDIT_VIEWS = ['ez_content_draft_edit', 'ezplatform.content.translate'];

/** @var \Symfony\Component\HttpFoundation\RequestStack */
private $requestStack;

public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}

public function getName()
{
return $this->getBlockPrefix();
Expand All @@ -35,4 +48,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->addModelTransformer(new DateValueTransformer());
}

public function buildView(FormView $view, FormInterface $form, array $options)
{
$request = $this->requestStack->getCurrentRequest();
$view->vars['isEditView'] = \in_array($request->attributes->get('_route'), self::EDIT_VIEWS);
}
}