1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys AirBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\BlogBundle\Form
;
14 use Symfony\Component\Form\Extension\Core\Type\TextType
;
15 use Symfony\Component\Form\FormBuilderInterface
;
16 use Symfony\Component\OptionsResolver\OptionsResolver
;
18 use Rapsys\UserBundle\Form\EditType
as BaseEditType
;
20 class EditType
extends BaseEditType
{
24 public function buildForm(FormBuilderInterface
$builder, array $options): FormBuilderInterface
{
25 //Call parent build form
26 $form = parent
::buildForm($builder, $options);
28 //Add extra pseudonym field
29 if (!empty($options['pseudonym'])) {
30 $form->add('pseudonym', TextType
::class, ['attr' => ['placeholder' => 'Your pseudonym'], 'required' => false]);
33 //Add extra slug field
34 if (!empty($options['slug'])) {
35 $form->add('slug', TextType
::class, ['attr' => ['placeholder' => 'Your slug'], 'required' => false]);
45 public function configureOptions(OptionsResolver
$resolver): void {
46 //Call parent configure options
47 parent
::configureOptions($resolver);
50 $resolver->setDefaults(['pseudonym' => true, 'slug' => false]);
52 //Add extra pseudonym option
53 $resolver->setAllowedTypes('pseudonym', 'boolean');
55 //Add extra slug option
56 $resolver->setAllowedTypes('slug', 'boolean');
62 public function getName(): string {
63 return 'rapsys_blog_edit';