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

Hi! Has anyone get the empty_value property of a MerchantPortal GUI form element to work? ```$builde

michael.schmetter
michael.schmetter Posts: 119 πŸ§‘πŸ»β€πŸš€ - Cadet

Hi!
Has anyone get the empty_value property of a MerchantPortal GUI form element to work?

$builder->add(
            static::FIELD_STORES,
            ChoiceType::class,
            [
                'choices' => $options[static::OPTION_STORE_CHOICES],
                'multiple' => true,
                'label' => static::LABEL_STORES,
                'required' => false,
                'empty_data' => [],
                'attr' => [
                    'placeholder' => static::PLACEHOLDER_STORES,
                ],
                'property_path' => 'storeRelation.idStores',
            ]
        );

I would like to set some default values for the forms, so in this case we only have one store, it should not be selected everytime, but regardless, what I put there it is not reflected in MP.
Currently I defaulted back to changing the value in the DataProviders for the form, but I would like the empty_data to work, since this is exactly what it is for.
Has somebody any idea?

Comments

  • U01A5ARAXP0
    U01A5ARAXP0 Posts: 119 πŸ§‘πŸ»β€πŸš€ - Cadet

    what exactly are you trying to achieve? What do you want to happen if no store is selected? And was exactly is happening now?

  • michael.schmetter
    michael.schmetter Posts: 119 πŸ§‘πŸ»β€πŸš€ - Cadet

    When creating a new product in MP I would like the store relation field to have the currently only present value prefilled, so that it does not need to be selected

  • U01A5ARAXP0
    U01A5ARAXP0 Posts: 119 πŸ§‘πŸ»β€πŸš€ - Cadet

    and what are you setting on the empty_data field?

  • michael.schmetter
    michael.schmetter Posts: 119 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited March 2022

    Tried it with

    'empty_data' => [1],
    'empty_data' => ['DE'],
    
  • U01A5ARAXP0
    U01A5ARAXP0 Posts: 119 πŸ§‘πŸ»β€πŸš€ - Cadet

    yes, it should work like that... maybe the data provider is always overriding that? Better debug it and see what happens...

  • U01A5ARAXP0
    U01A5ARAXP0 Posts: 119 πŸ§‘πŸ»β€πŸš€ - Cadet

    sorry I could not help you more