Tagged: 

Viewing 5 reply threads
  • Author
    Posts
    • #5053
      bubdev
      Member

      Hi,

      I have an Add-more group that is grouped together with a textfield, which is used for a heading. If the outer group is given a field name, the value of the text field isn’t showing. When I remove the field name, the value shows up but the whole construction somehow falls apart.

      Same situation with another nested group (value doesn’t show if outer group is given a name). But that one doesn’t have an addmore and therefore doesn’t fall apart when I remove the field name.

      Below is my code for the problematic Add-more group. I’m not sure if it’s a bug or if I’m doing it wrong.

      piklist('field', array(
        'type' => 'group'
        ,'field' => 'bub_title_shoplinks_container '
        ,'label' => __('Shoplinks') 
        ,'description' => __('Links zu den Produktseiten ausgewählter Shops.')
        ,'attributes' => array(
          'class' => 'bbe-group'
        )
        ,'fields' => array(
          array(
            'type' => 'text'
            ,'field' => 'bub_title_shoplinks_heading'
            ,'label' => __('Titel')
            ,'value' => 'Kaufen'
            ,'attributes' => array(
              'class' => 'bbe-title'
              ,'placeholder' => 'Eigener Titel'
            )
          )
          ,array(
            'type' => 'group'
            ,'field' => 'bub_title_shoplinks'
            ,'label' => __(' ')
            ,'attributes' => array(
              'class' => 'bbe-group'
            )
            ,'add_more' => true
            ,'fields' => array(
              array(
                'type' => 'text'
                ,'field' => 'bub_title_shoplinks_title'
                ,'label' => __('Beschriftung')
                ,'columns' => 4
                ,'attributes' => array(
                  'class' => 'bbe-text-left'
                  ,'placeholder' => 'Titel des Links'
                )
              )
              ,array(
                'type' => 'text'
                ,'field' => 'bub_title_shoplinks_address'
                ,'label' => __('Adresse (URL)')
                ,'columns' => 8
                ,'attributes' => array(
                  'class' => 'bbe-text-right'
                  ,'placeholder' => 'http://...'
                )
                // ,'validate' => array( // Validation errors for Links with '%' (e.g. Umlauts)
                //   array(
                //     'type' => 'url'
                //   )
                // )
              )
            )
          )
        )
      ));

      Thank you – Stefan

    • #5054
      bubdev
      Member

      And of course: When I say the value of the text field isn’t showing, I’m talking about the first text field (my heading) and it’s default value (‘value’ => ‘Kaufen’).

    • #5066
      bubdev
      Member

      Okay, this kind of nesting seems to be problematic in the first place (empty arrays). Now, after cleaning up the database and removing the outer group, it’s less pretty but it works again, including the default values showing up. 🙂

    • #5078
      Steve
      Keymaster

      @bubdev– We’ll take a look at this issue anyway.

      You could also just remove ,'field' => 'bub_title_shoplinks_container '. The data will now save as individual meta fields instead of in one big array.

      If you go this route, take a look at the data and make sure you are happy with it.

      Also, the default value shows up when I remove that field.

    • #5080
      bubdev
      Member

      That’s exactly how it was before it “suddenly” stopped working and I got “Illegal string offset” messages. However, now after deleting all corresponding entries from the database and trying again, everything works like a charme.

      Can this be a result of changing (and changing back) field names after there have already been made entries to the database? Because that’s probably something I’ve done.

      Thanks a lot, Steve.

    • #5082
      bubdev
      Member

      No, not working. After adding more than one add-more, all inputs loose their values, and the heading (‘bub_title_shoplinks_heading’) is being treated as part of the add-more.

      I used the exact same code as above without the outer field name. When I add it back in, the fields look fine in the backed but will stop working on the frontend, as experienced before.

      I think I’ll confine myself with the simpler variant for now.

Viewing 5 reply threads
  • You must be logged in to reply to this topic.