What are the Slack Archives?

Itโ€™s a history of our time together in the Slack Community! Thereโ€™s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you wonโ€™t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hello Team, Hope all are doing well! As part of learning, I'm trying to add a new field(Mobile Numb

U04F4JUC0UT
U04F4JUC0UT Posts: 35 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

Hello Team,

Hope all are doing well!
As part of learning, I'm trying to add a new field(Mobile Number) on SignUp page. I have extended the registerForm class in src\Pyz\Yves\Form\RegisterForm.php and added the new field there.
I have also updated the page-layout-login.twig but the field is not coming on the store

Can you please guide to the correct way of doing this?

Thanks

Comments

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Lรถffelhardt Spryker Solution Partner Posts: 871 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    Did u extended also the FormFactory that have to use your Pyz class instead of Spryker Class?

  • U04F4JUC0UT
    U04F4JUC0UT Posts: 35 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    No I have not used FormFactory can you please help me where I have to do that

  • U04F4JUC0UT
    U04F4JUC0UT Posts: 35 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    Should I extend it inside form?

  • U04F4JUC0UT
    U04F4JUC0UT Posts: 35 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet
        public function getRegisterForm()
        {
            return $this->getFormFactory()->create(RegisterForm::class);
        }
    

    Do I have to override this?

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Lรถffelhardt Spryker Solution Partner Posts: 871 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    Yes.. just this one, and use the Pyz RegisterForm in use statement..

  • U04F4JUC0UT
    U04F4JUC0UT Posts: 35 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    Thanks for the reply,
    I have added this,

    public function getRegisterForm()
        {
            return $this->parent::getFormFactory()->create(SignUpForm::class);
        }
    
  • U04F4JUC0UT
    U04F4JUC0UT Posts: 35 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    Can you please have a look is it correct?

  • U04F4JUC0UT
    U04F4JUC0UT Posts: 35 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    ร€nd in the page-layout-login.twig I have added the new field, is it the correct way,

    layout: {
                                salutation: 'col col--sm-12 col--md-3',
                                first_name: 'col col--sm-12 col--md-4',
                                last_name: 'col col--sm-12 col--md-5',
                                mobile_number: 'col col--sm-12 col--md-5',
                                password: 'col col--sm-12 col--md-6',
                            }
    
  • U04F4JUC0UT
    U04F4JUC0UT Posts: 35 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet
    edited December 2022

    Hi @florian.scholz, can you please help here.

    Thanks

  • U04F4JUC0UT
    U04F4JUC0UT Posts: 35 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet
    edited December 2022

    Here is the code where I have extended the register class

    use SprykerShop\Yves\CustomerPage\Form\RegisterForm;
    use Symfony\Component\Form\Extension\Core\Type\TextType;
    use Symfony\Component\Form\FormBuilderInterface;
    
    /**
     * @method \SprykerShop\Yves\CustomerPage\CustomerPageConfig getConfig()
     */
    class SignUpForm extends RegisterForm
    {
        /**
         * @var string
         */
        public const FIELD_MOBILE_NUMBER = 'mobile_number';
    
        /**
         * @return string
         */
        public function getBlockPrefix()
        {
            return static::BLOCK_PREFIX;
        }
    
        /**
         * @param \Symfony\Component\Form\FormBuilderInterface $builder
         * @param array $options
         *
         * @return void
         */
        public function buildForm(FormBuilderInterface $builder, array $options)
        {
            parent::buildForm($builder, $options);
            $this->addMobileNumberField($builder);
        }
    
  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 โš–๏ธ - Guardians (admin)

    Hey, please have a look at this brand new elearning: https://academy.spryker.com/learn/course/external/view/elearning/481/project-customization

    In the hands-on task in the end of that session you will extend the ProfileForm and add another form field. The steps there should be the same as in your use-case. This should give you hopefully some more understanding