Tagged: image select, repeater, wordpress4.5
- This topic has 4 replies, 2 voices, and was last updated 5 years, 9 months ago by
adrianm.
-
AuthorPosts
-
-
April 21, 2016 at 2:05 am #6332
adrianmMemberThis 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.
-
April 21, 2016 at 2:16 am #6333
adrianmMemberCorrection:
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. -
April 21, 2016 at 2:33 am #6334
adrianmMemberUpon 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. -
April 23, 2016 at 9:22 pm #6346
-
April 28, 2016 at 2:42 pm #6399
adrianmMemberIt 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.
-
-
AuthorPosts
- You must be logged in to reply to this topic.