Viewing 5 reply threads
  • Author
    Posts
    • #2357
      Simon
      Member

      I cannot seem to get two file fields to work correctly inside an “add_more”. When selecting images for the 2nd field in the 2nd or subsequent item, the images are all added to the first item when saved.

      piklist('field', [
       'type' => 'group',
       'add_more' => true,
       'template' => 'field',
       'fields' => [
         ['type' => 'file', 'field' => 'flavour-images', 'label' => 'Image(s)'],
         ['type' => 'file', 'field' => 'flavour-nutrition-info', 'label' => 'Nutritional info'],
       ]
      ]);

      The same issue occurs when using 'basic' => true. Is this a bug? Or am I doing something wrong?

    • #2411
      Steve
      Keymaster

      @simon– All fields in the fields parameter need to be in an array. This will work:

      piklist('field', array(
        'type'    => 'group',
        'template' => 'field',
        'add_more'=> true,
        'fields'  => array(
          array(
            'type'      => 'file',
            'field'     => 'flavour-images',
            'label'     => 'Image(s)',
          ),
          array(
            'type'      => 'file',
            'field'     => 'flavour-nutrition-info',
            'label'     => 'Nutritional info',
          )
        )
      ));
      
    • #2427
      Simon
      Member

      Steve, your array and my array are exactly the same (except that I used the short array syntax available in PHP 5.4+).

      Have you tried that code and got it to save successfully for 2 or more items?

    • #2428
      Steve
      Keymaster

      @simon– You’ve actually found two bugs:
      1) This configuration does not play nice with the field template.
      2) They don’t save properly.

      We will work on a fix.

    • #2495
      Steve
      Keymaster

      @simon– You will need to specify the number of columns when using this template and a group field.

      piklist('field', array(
        'type'    => 'group',
        'template' => 'field',
        'add_more'=> true,
        'fields'  => array(
          array(
            'type'      => 'file',
            'field'     => 'flavour-images',
            'label'     => 'Image(s)',
            'columns' => 12
          ),
          array(
            'type'      => 'file',
            'field'     => 'flavour-nutrition-info',
            'label'     => 'Nutritional info',
            'columns' => 12
          )
        )
      ));
      
    • #2496
      Simon
      Member

      I assume this only fixes the layout, but not the saving issue?

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