black friday sale

Custom Fields
Re-Envisioned
Support General not flatten select

  • Creator
    Topic
  • #22620
    Resolved Aart Jan van der Linden
    Participant

    Hi!

    I’m facing an issue where a select is not saving data when the options-array is not flat. I even tried using your exact demo-data, but it’s not saved.
    The selected value does make it into the POST headers, so it looks like some sort of validation that stops the data from being saved? The plugin even overwrites manually entered data, so it seems to be convinced that the field should be empty.
    Changing ‘flatten’ to true/false does not seem to help.

    'fields' => [
                        [
                            'name' => 'Beroep',
                            'id' => 'profession',
                            'type' => 'select',
                            'flatten'=>false,
                            'options' => array(
                              array( 'value' => 'monkeys', 'label' => 'Monkeys' ),
                              array( 'value' => 'king_kong', 'label' => 'King Kong', 'parent' => 'monkeys' ),
                              array( 'value' => 'curious_george', 'label' => 'Curious George', 'parent' => 'monkeys' ),
                              array( 'value' => 'donkeys', 'label' => 'Donkeys' ),
                              array( 'value' => 'eeyore', 'label' => 'Eeyore', 'parent' => 'donkeys' ),
                              array( 'value' => 'guss', 'label' => 'Gus', 'parent' => 'donkeys' ),
                             ),
                        ],
Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #22621

    I think I found a solution: it works if the options array has keys:

    'fields' => [
                        [
                            'name' => 'Beroep',
                            'id' => 'profession',
                            'type' => 'select',
                            'flatten'=>false,
                            'options' => array(
                              'monkeys'=> array( 'value' => 'monkeys', 'label' => 'Monkeys' ),
                              'king_kong' => array( 'value' => 'king_kong', 'label' => 'King Kong', 'parent' => 'monkeys' ),
                              'curious_george' => array( 'value' => 'curious_george', 'label' => 'Curious George', 'parent' => 'monkeys' ),
                              'donkeys' => array( 'value' => 'donkeys', 'label' => 'Donkeys' ),
                              'eeyore' => array( 'value' => 'eeyore', 'label' => 'Eeyore', 'parent' => 'donkeys' ),
                              'guss' => array( 'value' => 'guss', 'label' => 'Gus', 'parent' => 'donkeys' ),
                             ),
                        ],
    #23133
    Anh Tran
    Keymaster

    Hi,

    Thanks a lot for your feedback. This is an edge-case in the plugin and I’ve fixed it on Github, which will be added in the next version.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.