Forum Replies Created
-
AuthorPosts
-
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.
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.
PhilParticipantI’m guessing you could give the
available_sectionsavaluethat is an array like this:'value' => array('Default 1', 'Default 2', 'Default 3')
PhilParticipantI’m getting started with Piklist and loving it. Thank you!
I came across this same issue of default values not displaying for fields in groups, also mentioned here. I’m running WP 4.5.3, Piklist 0.9.9.9, twentyfifteen theme.
To reproduce, visit Piklist Demos > Add New >
- Common > Lists > Checkbox/Radio Fields > Group Lists
- Add More’s > Single Level > Newsletter Signup
I experienced the missing default
valuewith field typestextandfile.Here’s a patch that seems to work, but I’m not familiar with Piklist, so I’m sure you’ll come up with a more integrated implementation.
diff --git includes/class-piklist-form.php includes/class-piklist-form.php index 19acf4a..01ebc18 100755 --- includes/class-piklist-form.php +++ includes/class-piklist-form.php @@ -2539,6 +2539,9 @@ class Piklist_Form foreach ($field['fields'] as $column) { + // Record default value + $column['default_value'] = $column['value']; + // Set index $column['index'] = $index; @@ -2633,6 +2636,12 @@ class Piklist_Form } } + // Use default value if necessary + if (is_null($column['value'])) + { + $column['value'] = $column['default_value']; + } + $content .= self::render_field($column, true); } } -
AuthorPosts