Skip to content

remove template's parent type because we use template property for this #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2016
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
22 changes: 6 additions & 16 deletions Bundle/CoreBundle/Form/ViewType.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,19 @@ public function buildForm(FormBuilderInterface $builder, array $options)
]);
}
if (!$form->has('locale') && count($choices = $this->getAvailableLocales($view)) > 1) {
$data = $view->getLocale() ?: $this->currentLocale;
$form->add('locale', 'choice', [
'expanded' => false,
'multiple' => false,
'choices' => $choices,
'label' => 'form.view.type.locale.label',
'data' => $this->currentLocale,
'data' => $data,
]
);
}

//If view is either a BEPP or a BEP and is not an Article BEP, we do not allow to choose parent because it will be set
if (!$view instanceof ArticleTemplate) {
// vérifie si l'objet Product est "nouveau"
// Si aucune donnée n'est passée au formulaire, la donnée est "null".
// Ce doit être considéré comme une nouvelle "View"
//If view is an Article BEP, we do not allow to choose parent because it will be set automatically
if (!$view instanceof ArticleTemplate && ClassUtils::getClass($view) != 'Victoire\Bundle\TemplateBundle\Entity\Template') {
if (!$view || null === $view->getId()) {
$getAllPageWithoutMe = function (EntityRepository $repo) {
return $repo->getAll()->getInstance();
Expand All @@ -97,22 +95,14 @@ public function buildForm(FormBuilderInterface $builder, array $options)
};
}

if (ClassUtils::getClass($view) == 'Victoire\Bundle\TemplateBundle\Entity\Template') {
$class = 'Victoire\Bundle\TemplateBundle\Entity\Template';
$required = false;
} else {
$class = 'Victoire\Bundle\PageBundle\Entity\BasePage';
$required = true;
}

$form->add(
'parent',
null,
[
'class' => $class,
'class' => 'Victoire\Bundle\PageBundle\Entity\BasePage',
'label' => 'form.view.type.parent.label',
'query_builder' => $getAllPageWithoutMe,
'required' => $required,
'required' => true,
]
);
}
Expand Down