Viewing 4 reply threads
  • Author
    Posts
    • #6332
      adrianm
      Member

      This is the field I have

      
      piklist('field', array(
          'type' => 'group',
          'field' => 'slides',
          'label' => __('Slides'),
          'template' => 'field',
          'list' => false,
          'add_more' => true,
          'fields' => array(
              array(
                  'type' => 'file',
                  'field' => 'image',
                  'columns' => 12,
                  'options' => array(
                      'modal_title' => __('Select image', 'app'),
                      'button' => __('Select image', 'app')
                  )
              ),
              array(
                  'type' => 'text',
                  'field' => 'title',
                  'columns' => 6,
                  'attributes' => array(
                      'placeholder' => 'Title'
                  )
              ),
              array(
                  'type' => 'text',
                  'field' => 'link',
                  'columns' => 6,
                  'attributes' => array(
                      'placeholder' => 'URL (optional)'
                  )
              ),
              array(
                  'type' => 'textarea',
                  'field' => 'content',
                  'columns' => 12,
                  'attributes' => array(
                      'rows' => 3,
                      'placeholder' => 'Description'
                  )
              ),
          )
      ));
      

      When creating a post, the image is not saved (the rest of the fields are) but if I populated the field directly in the DB and edit the post everything works fine.

      It doesn’t save the image if, from an existing post, I delete the image and try to add again.

      From what I saw the problem is that the _post_meta[slides][0][image][] input fields are not updated correctly. When you remove the image the value of the associated field is cleared, but the input stays on the homepage and when you add an image there is not input field appended to the DOM.

      I think this might cause problems with ALL the image selector fields not just in the repeater.

    • #6333
      adrianm
      Member

      Correction:

      From what I saw the problem is that the _post_meta[slides][0][image][] input fields are not updated correctly. When you remove the image the value of the associated field is cleared, but the input stays on the DOM and when you add an image there is not input field appended to the DOM.

    • #6334
      adrianm
      Member

      Upon some investigation I think the issue is because you don’t put the hidden input fields inside the .piklist-field-preview . The HTML code coming from the server seems correct but I think your JS is moving things around. I hope this can help you fix this issue sooner.

    • #6346
      Steve
      Keymaster

      @adrianm– Thanks for letting us know. We’ll get this fixed in the next version.

    • #6399
      adrianm
      Member

      It seems the issue comes from this section

      
                if (!$element.hasClass('wp-editor-wrap'))
                {
                  $element = $element.addBack();  // I COMMENTED THIS LINE AND IT WORKS
                }
      

      That makes the hidden input be moved in the DOM.

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