resolution lenteur sur submit/update blogarticle (ref #180)
This commit is contained in:
parent
936b6810b0
commit
cb5b98237d
|
@ -26,14 +26,16 @@ class BlogarticleController extends Controller
|
||||||
return $this->createForm(BlogarticleType::class, $entity, [
|
return $this->createForm(BlogarticleType::class, $entity, [
|
||||||
"mode" => "update",
|
"mode" => "update",
|
||||||
"access" => $access,
|
"access" => $access,
|
||||||
"user" => $this->getUser()
|
"user" => $this->getUser(),
|
||||||
|
'blogarticle' => $entity,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return $this->createForm(BlogarticleType::class, $entity, [
|
return $this->createForm(BlogarticleType::class, $entity, [
|
||||||
"mode" => "submit",
|
"mode" => "submit",
|
||||||
"access" => $access,
|
"access" => $access,
|
||||||
"user" => $this->getUser()
|
"user" => $this->getUser(),
|
||||||
|
'blogarticle' => $entity,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ class BlogarticleType extends AbstractType
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$user=$options['user'];
|
$user=$options['user'];
|
||||||
|
$blogarticle=$options['blogarticle'];
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('submit', SubmitType::class, [
|
->add('submit', SubmitType::class, [
|
||||||
|
@ -60,6 +61,7 @@ class BlogarticleType extends AbstractType
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if(!$blogarticle->getBlog()) {
|
||||||
$builder
|
$builder
|
||||||
->add('blog', EntityType::class, [
|
->add('blog', EntityType::class, [
|
||||||
'label' => 'Blog associé',
|
'label' => 'Blog associé',
|
||||||
|
@ -84,6 +86,23 @@ class BlogarticleType extends AbstractType
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$builder
|
||||||
|
->add('blog', EntityType::class, [
|
||||||
|
'label' => 'Blog associé',
|
||||||
|
'class' => 'CadolesPortalBundle:Blog',
|
||||||
|
'choice_label' => 'name',
|
||||||
|
"disabled" => ($options["mode"]=="update"?true:false),
|
||||||
|
'placeholder' => '-- Sélectionnez un Blog --',
|
||||||
|
'query_builder' => function(EntityRepository $er) use ($blogarticle) {
|
||||||
|
$qb=$er->createQueryBuilder('blog');
|
||||||
|
return $qb->select('blog')
|
||||||
|
->where('blog.id=:blog')
|
||||||
|
->setparameter('blog',$blogarticle->getBlog()->getId());
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
@ -92,7 +111,8 @@ class BlogarticleType extends AbstractType
|
||||||
'data_class' => 'Cadoles\PortalBundle\Entity\Blogarticle',
|
'data_class' => 'Cadoles\PortalBundle\Entity\Blogarticle',
|
||||||
'mode' => 'string',
|
'mode' => 'string',
|
||||||
'access' => 'string',
|
'access' => 'string',
|
||||||
'user' => 'Cadoles\CoreBundle\Entity\User'
|
'user' => 'Cadoles\CoreBundle\Entity\User',
|
||||||
|
'blogarticle' => 'Cadoles\PortalBundle\Entity\Blogarticle'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue