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..

Hey, a quickie. I would like to add some fields to the `CustomerForm` in the Backoffice. I could do

U04BCHQVACE
U04BCHQVACE Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet
edited March 2023 in Help

Hey, a quickie. I would like to add some fields to the CustomerForm in the Backoffice. I could do that by extending the CustomerForm class and overriding the build method, and then overriding the factory, etc. However, I'm not sure how to handle the processing of the resulting DTO.

How to best do this? Is it actually possible to add fields to the CustomerForm or is it better to just add my fields in another screen in BO? Any sort of guidance on what would be the best way to achieve my goal would be greatly appreciated. ๐Ÿ™‚

Comments

  • U04BCHQVACE
    U04BCHQVACE Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    I've seen the CustomerModel has a plugin system. Is the case that I should tap into that?

  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    I would simply extend the CustomerForm on project level, override buildForm and add my custom field(s) and add these fields to the spy_customer.schema.xml and customer.transfer.xml as well. should be it

  • U04BCHQVACE
    U04BCHQVACE Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    Yes, I can do that, but then how do I process the newly added fields in the transfer? For instance, one of those fields is dietaryPreferences , and I want to save those on a separate table.

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 ๐Ÿช - Explorer

    Why do you want to save that on a separate table? One of the benefits of Spryker is that you can extend already existing tables and do not need to query two tables because of an extension.
    It might still be valid to use a separat table, then you will need to extend \Spryker\Zed\Customer\Business\Customer\Customer::update in your project and implement a \Spryker\Zed\Customer\Dependency\Plugin\CustomerTransferExpanderPluginInterface to add those new fields to the CustomerTransfer so you are able to use it in Yves/Glue.

  • U04BCHQVACE
    U04BCHQVACE Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    Excellent. Thanks @UL6DGRULR!

    Yes, I need a separate table because what I need to add to the customer is a collection of things.

  • U04BCHQVACE
    U04BCHQVACE Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    I understand that is a new "entity" strictly speaking, but I was just wondering if I could extend the customer form because these are things closely related to the customer.

  • U04BCHQVACE
    U04BCHQVACE Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    But I think my only option might be to create a new screen in BO to define those values. Seems simpler.