Viewing 7 reply threads
  • Author
    Posts
    • #6929
      visualtricks
      Member

      Hi, 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?

    • #6969
      visualtricks
      Member

      Sorry 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..

    • #6974
      Steve
      Keymaster

      @visualtricks– Can you post the entire group field here?

    • #6977
      visualtricks
      Member

      Yep, 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.
    • #6979
      Steve
      Keymaster

      @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 value should work.

      Example:

      $fritto_1_ita = get_post_meta(get_the_ID(), 'fritto_1_ita', true);

    • #6980
      visualtricks
      Member

      Thanks for the prompt reply, I’ll give it a try!

      Cheers
      Massimiliano

    • #7159
      Phil
      Participant

      I’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 value with field types text and file.

      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);
             }
           }
      
    • #7174
      Steve
      Keymaster

      @phil– Welcome to the Piklist community, and thanks for the patch!

      This will be fixed in the next version of Piklist.

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