Tagged: default, group field, value
- This topic has 7 replies, 3 voices, and was last updated 5 years, 5 months ago by
Steve.
-
AuthorPosts
-
-
July 10, 2016 at 10:58 am #6929
visualtricksMemberHi, after the last update the default ‘value’ I set in text field doesn’t show up anymore (was working fine before). Here’s my code:
array( 'type' => 'text' ,'field' => 'secondo_1_ita' ,'columns' => 8 ,'label' => 'secondo 1' ,'value' => 'Bistecca alla Fiorentina con patate arrosto' ,'attributes' => array('placeholder' => 'secondo 1 Italiano') )The text field is (one) part of a group field, used in the backend on a custom post type (not registered via piklist).
Am I doing something wrong? -
July 18, 2016 at 11:03 am #6969
visualtricksMemberSorry to bump up, but has anyone experienced something like that or have any idea how to solve it? I’ve tried reinstalling pklist, and tried the field on another custom post, with no luck..
-
July 19, 2016 at 10:06 am #6974
SteveKeymaster@visualtricks– Can you post the entire group field here?
-
July 19, 2016 at 10:29 am #6977
visualtricksMemberYep, no problem. I found out that is happening only when text fields are grouped, single ungrouped text fields are working as expected.
piklist('field', array( 'type' => 'group' ,'field' => 'group_test' ,'label' => __('group test') ,'columns' => 12 ,'fields' => array( array( 'type' => 'text' ,'field' => 'fritto_1_ita' ,'columns' => 8 ,'label' => 'fritto 1' ,'value' => 'Coccole con prosciutto e stracciatella' ,'attributes' => array('placeholder' => 'Italiano') ) ,array( 'type' => 'text' ,'field' => 'fritto_1_eng' ,'columns' => 8 ,'value' => 'Deep-fried dough balls with ham and stracciatella cheese' ,'attributes' => array('placeholder' => 'Inglese') ) ,array( 'type' => 'text' ,'field' => 'fritto_1_prezzo' ,'columns' => 3 ,'value' => '8 €' ,'attributes' => array('placeholder' => 'prezzo') ) ) ) ); piklist('field', array( 'type' => 'text' ,'field' => 'single_test' ,'columns' => 8 ,'label' => 'single test' ,'value' => 'Coccole con prosciutto e stracciatella' ,'attributes' => array('placeholder' => 'single test') ) );Attachments:
You must be logged in to view attached files. -
July 19, 2016 at 11:12 am #6979
SteveKeymaster@visualtricks– We’ll look into fixing this.
In the meantime, you can “ungroup” this group field by removing:
,'field' => 'group_test'Using that field saves everything into an array. By removing it the individual keys are saved independently, but the layout remains.
You will have to retrieve the data separately, but the
valueshould work.Example:
$fritto_1_ita = get_post_meta(get_the_ID(), 'fritto_1_ita', true); -
July 19, 2016 at 11:18 am #6980
visualtricksMemberThanks for the prompt reply, I’ll give it a try!
Cheers
Massimiliano -
August 14, 2016 at 12:51 am #7159
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); } } -
August 17, 2016 at 4:18 pm #7174
-
-
AuthorPosts
- You must be logged in to reply to this topic.