Tagged: add_more
- This topic has 7 replies, 2 voices, and was last updated 5 years, 5 months ago by
Dan.
-
AuthorPosts
-
-
August 27, 2016 at 6:27 am #7260
DanParticipantHi, Is there a way to auto populate the add more fields by default?
For example, on creation of a new post I would like to display 3 text fields, but the user could delete or change these as appropriate?
-
August 27, 2016 at 6:50 am #7261
-
August 28, 2016 at 7:30 pm #7263
-
August 29, 2016 at 4:09 am #7264
DanParticipantHi phil,
I’ve tried this, doesn’t seem to work as a child add more.
I’ve done a work around for now, adding this into a settings page and showing this as a multi select.
Cheers
-
August 29, 2016 at 3:45 pm #7266
PhilParticipantThis code produces the attached screenshot for me (Piklist 0.9.9.9, WP 4.6):
piklist('field', array( 'type' => 'group' ,'field' => 'classes' ,'label' => 'Classes' ,'add_more' => true ,'fields' => array( array( 'type' => 'text' ,'field' => 'class' ,'label' => 'Class Name' ,'columns' => 12 ) ,array( 'type' => 'text' ,'field' => 'members' ,'label' => 'Members' ,'columns' => 6 ) ,array( 'type' => 'text' ,'field' => 'non_members' ,'label' => 'Non-Members' ,'columns' => 6 ) ,array( 'type' => 'text' ,'field' => 'section' // ,'label' => 'Section' ,'add_more' => true ,'columns' => 12 ,'attributes' => array('placeholder' => 'Section Name') ,'value' => array('Section 1', 'Section 2', 'Section 3') ) ) ));But when you say it “doesn’t seem to work as a child add more,” perhaps you are referring to this limitation:
Currently, default values for our Add-Mores only work on the initial field. We have it on our list to make it work on every add_more.
This means that if you add an additional class, it won’t display the three default sections. Only the initial class will show defaults.
Attachments:
You must be logged in to view attached files. -
August 29, 2016 at 3:58 pm #7269
DanParticipantThat’s really odd, I’m also on Piklist 0.9.9.9, WP 4.6 but I do not get the default fields come through?
Copied your example into mine just in case I had a typo, but still not getting the desired results.
<?php /* Title: Classes Post Type: mrc-event Order: 200 */ piklist('field', array( 'type' => 'group' ,'field' => 'classes' ,'label' => 'Classes' ,'add_more' => true ,'fields' => array( array( 'type' => 'text' ,'field' => 'class' ,'label' => 'Class Name' ,'columns' => 12 ) ,array( 'type' => 'text' ,'field' => 'members' ,'label' => 'Members' ,'columns' => 6 ) ,array( 'type' => 'text' ,'field' => 'non_members' ,'label' => 'Non-Members' ,'columns' => 6 ) ,array( 'type' => 'text' ,'field' => 'section' // ,'label' => 'Section' ,'add_more' => true ,'columns' => 12 ,'attributes' => array('placeholder' => 'Section Name') ,'value' => array('Section 1', 'Section 2', 'Section 3') ) ) ));Attachments:
You must be logged in to view attached files. -
August 29, 2016 at 4:16 pm #7271
PhilParticipant@Dan I owe you an apology because I posted all that forgetting that I had applied this patch, So I wasn’t working with a clean copy of Piklist. When I revert that patch, I see the exact same problem you described.
I guess it’s up to you whether to modify the Piklist core files with that patch. Again, my apologies.
-
August 29, 2016 at 4:18 pm #7272
DanParticipantDon’t apologise, this is exactly what I needed. Thank you!
-
-
AuthorPosts
- You must be logged in to reply to this topic.