Skip to content
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

Can't create a registration/profile form without an address and note #45

Closed
nickvanderzwet opened this issue Oct 26, 2016 · 2 comments
Closed
Labels
Milestone

Comments

@nickvanderzwet
Copy link

Q A
Bug? no
New Feature? yes
Sulu Version 7d98fff
Browser Version Any

Actual Behavior

https://github.com/sulu/SuluCommunityBundle/blob/develop/Controller/ProfileController.php#L137

Sulu adds by default an address and a note. If you don't want this (only a form with the basic profile info such as username) it's almost not possible to skip this step.

Expected Behavior

It is possible to don't include an address/note field.

Steps to Reproduce

Save the form without the required address/note

screen shot 2016-10-26 at 13 19 27

Possible Solutions

Make this configurable or perhaps make addAddress / addNote protected instead of private. So it can be overwritten in a client specific class.

@alexander-schranz
Copy link
Member

alexander-schranz commented Dec 20, 2016

If you want no address or note in your form you need todo the following:

sulu_community:
    webspaces:
        <your_webspace>:
            registration:
                type: AppBundle\Form\Type\RegistrationType

There you need to write the following:

<?php

namespace AppBundle\Form\Type;

use Sulu\Bundle\CommunityBundle\Form\Type\RegistrationType as SuluRegistrationType;
use Symfony\Component\OptionsResolver\OptionsResolver;

class RegistrationType extends SuluRegistrationType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
         parent::buildForm(FormBuilderInterface $builder, array $options);
    }

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'contact_type' => RegistrationContactType::class,
                'contact_type_options' => ['label' => false],
            ]
        );
    }
}
<?php

namespace AppBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

class RegistrationContactType extends AbstractType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('firstName', TextType::class);
        $builder->add('lastName', TextType::class);
    }
}

@alexander-schranz alexander-schranz added this to the 1.0.0 milestone Mar 6, 2017
@alexander-schranz
Copy link
Member

@nickvanderzwet when reading your error message again this seems to be missing in your custom form: https://github.com/sulu/SuluCommunityBundle/blob/1.0.0-RC1/Form/Type/ProfileContactAddressType.php#L28-L31

If this don't help feel free to reopen this issue.

alexander-schranz pushed a commit to alexander-schranz/SuluCommunityBundle that referenced this issue Dec 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants