Tagged: , ,

Viewing 3 reply threads
  • Author
    Posts
    • #1245
      Marcus
      Member

      Just wondering if anyone has brought this bug up.

      When I create a radio button(s), if I create it inside a group with a field, I can set the value and it is saved.

      ,'field' => 'fieldname'
      ,'fields' => array (
          array(
            'type' => 'radio'
            ,'field' => 'mae_ch_gender'
            ,'label' => 'Male or Female'
            ,'choices' => array(
              'm' => 'M'
              ,'f' => 'F'
            )
            ,'columns' => 4
         )
      )
      

      If I create a radio button outside of a group, on its own, I can set the value and its saved.

       piklist('field', array(
            'type' => 'radio'
            ,'field' => 'mae_ch_gender'
            ,'label' => 'Male or Female'
            ,'choices' => array(
              'm' => 'M'
              ,'f' => 'F'
            )
            ,'columns' => 4
      ));
      

      If I create a radio button inside a group, that has no field set, when I set a value, or choose a value it will not save. Or at least will not show the saved option.

      ,'fields' => array(
          array(
            'type' => 'radio'
            ,'field' => 'mae_ch_gender'
            ,'label' => 'Male or Female'
            ,'choices' => array(
              'm' => 'M'
              ,'f' => 'F'
            )
            ,'columns' => 4
          )
      )
      

      Marcus

    • #1246
      Marcus
      Member

      I should have added. That the field itself has a field name. Just the outer group doesn’t. And every other control within that group does save properly.

      Marcus

    • #1247
      Marcus
      Member

      Just wanted to give you guys an update in case you were looking at this.
      I’ve gone through the class-piklist-form.php file.

      For the other two scenarios, a radio button inside a grouped piklist function, with a field value, and the radio button on its own, in its own piklist function, we’ll call scenario 1.

      Scenario 2 is a radio button inside a grouped piklist function WITHOUT a field name set.

      So going through the file, I can see where the $field is being built, is where things seem to breakdown, by the time, get_field_value is executed, the $field[‘template’] has changed to $field[‘template’] = ‘field’ instead of $field[‘template’] = ‘radio’ (explaining why all my normal fields aren’t affected by this, only the radio button) So even though its set to ‘radio’ in the arguments, it changes to ‘field’ by the time the field vars are built.

      I’m not quite sure why this change happens, but its like I said, it doesn’t if the group has a named field (which means it automatically arrays all fields within it, which is not what I want, but I do want the visual grouping and organizing aspect, so I need to use it without the field name)

      hope this helps.

      Marcus

    • #1249
      Marcus
      Member

      Unfortunately I really should have tested things out, before trying to roll this out to the client.

      I’m in a bit of a dilemma.

      What I said above, is inaccurate.

      Checkboxes DON’T work if the group has a named field and there is more than 1 choice. At least for me.

      I’ve tried everything, but still anything NON-FIELD related, radio, checks, don’t work in groups properly if there is more than 1 choice.

      As happens with the following code:

      
      piklist('field', array(
      	'type' => 'group'
      	,'add_more' => true
      	,'scope' => 'post_meta'
      	,'label' => 'Week Bookings'
      	,'field' => 'mae_sched_weeks'
      	,'description' => 'Here you can book each week individually and set the number of days for that week.'
      	,'columns' => 12
      	,'attributes' => array (
      	)
      	,'fields' => array (
      		array (
      			'type' => 'select'
      			,'field' => 'mae_sched_choose_week'
      			,'label' => 'Choose Week'
      			,'attributes' => array (
      				'class' => array (
      					'chooseweek'
      				)
      			)
      			,'columns' => 6
      			, 'choices' => piklist(
      				$wpdb->get_results("SELECT 
      				w.ID AS weekID, CONCAT('Week ',w.menu_order, ' (',REPLACE(wc1.meta_value,', ".$weekyear."',''),' - ',wc2.meta_value,')') AS weekTitle 
      				FROM {$wpdb->prefix}posts w
      				LEFT JOIN {$wpdb->prefix}posts wp ON wp.post_title='".$weekyear."' AND wp.post_type=w.post_type
      				LEFT JOIN {$wpdb->prefix}postmeta wc1 ON w.ID = wc1.post_id AND wc1.meta_key='mae_wks_start_week'
      				LEFT JOIN {$wpdb->prefix}postmeta wc2 ON w.ID = wc2.post_id AND wc2.meta_key='mae_wks_end_week'
      				WHERE w.post_parent = wp.ID AND w.post_type='weeks'
      				ORDER BY w.menu_order"), array("weekID","weekTitle")
      			)
      			,'on_post_status' => array(
      			  'value' => 'lock'
      			)
      		)
      		,array (
      			'type' => 'checkbox'
      			,'field' => 'mae_sched_act_days'
      			,'' => 'post_meta'
      			,'label' => 'Select Active Days'
      			,'value' => array (
      				'2','3','4','5','6'
      			)
      			,'attributes' => array (
      				'class' => 'text'
      			)
      			,'position' => 'wrap'
      			,'choices' => array(
      				'1'=>'s'
      				,'2'=>'m'
      				,'3'=>'t'
      				,'4'=>'w'
      				,'5'=>'t'
      				,'6'=>'f'
      				,'7'=>'s'
      			)
      			,'columns' => 6
      			,'on_post_status' => array(
      			  'value' => 'lock'
      			)
      		)
      	)
      ));
      

      I’ve checked and there are no duplicate field names, and I think I’m using the fields properly. 🙂

      Any chance that an update is coming, as these things are quite critical for me right now.

      Thanks Guys.

      Marcus

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