Viewing 5 reply threads
  • Author
    Posts
    • #4595
      justin
      Member

      I think the post_relate functionality is pretty cool. I have noticed a few things.

      When you want to only allow a single selection to be made for the relate_post, it does not work properly. Because it does not delete the past relationships that it created.

      piklist('field', array(
      		 'type' => 'select'
      		 ,'field' => '_' . piklist::$prefix . 'relate_post'
      		 ,'choices' => piklist(
      		   get_posts(array(
      			 'post_type' => 'post_mission_trip'
      			 ,'numberposts' => -1
      			 ,'orderby' => 'meta_value_num'
      			 ,'meta_key' => 'trip_begin'
      			 ,'order' => 'DESC'
      			 ,'post_status' => 'any'
      		   ))
      		   ,array('ID', 'post_title')
      		 )
      		 ,'relate' => array(
      		   'scope' => 'post'
      		 )
      	   ));

      The above code will cause duplicate relationships.

      Also I notice that on the front-end the checkbox version of the code above works fine inside of user’s profiles, except that the system keeps saving weird meta_keys in the user _meta table that seem to be just strings of letter/numbers. I attached an image with highlighted meta_keys that were created after I added the checkbox version of the relate_post field to my user_profile.

      Attachments:
      You must be logged in to view attached files.
    • #4597
      Kevin
      Keymaster

      @Justin-

      Check out the latest version we just released (0.9.9.3). The additional odd fields are actually the html fields, they were being saved in the previous release and thats been resolved.

      Thanks,

      Kevin

    • #4598
      Kevin
      Keymaster

      Also please make sure you only have the one Piklist field on the page named __relate_post (‘_’ . piklist::$prefix . ‘relate_post’) or the last one submitted will always take over in the save process.

      Thanks,

      Kevin

    • #4636
      justin
      Member

      Hi Kevin,

      I have updated to 0.9.9.4, and the field only works as a checkbox. When I save it as a select field and try and change the value, when it saves, it has saved the new record and did not remove the old one.

      I looked in the database, and the post I am editing, only keeps one __relate_post meta, but it does not delete the __relate_post of the last related post it was related too.

      Here is the field:

      piklist('field', array(
      		 'type' => 'select'
      		 ,'field' => '_' . piklist::$prefix . 'relate_post'
      		 ,'label' => __('Mission Trip', 'extreme')
      		 ,'choices' => piklist(
      		   get_posts(array(
      			 'post_type' => 'post_mission_trip'
      			 ,'numberposts' => -1
      			 ,'orderby' => 'meta_value_num'
      			 ,'meta_key' => 'trip_begin'
      			 ,'order' => 'DESC'
      			 ,'post_status' => 'any'
      		   ))
      		   ,array('ID', 'post_title')
      		 )
      		 ,'relate' => array(
      		   'scope' => 'post'
      		 )
      	   ));

      I am not using any other relate_post fields with this post type or in the metabox.

    • #4637
      Kevin
      Keymaster

      @Justin-

      I tried the following field below and it works as expected (I just swapped the choices). Can you try it? Also please make sure you don’t have any other __relate_post fields on the form at all.

      piklist('field', array(
        'type' => 'select'
        ,'field' => '_' . piklist::$prefix . 'relate_post'
        ,'label' => __('Mission Trip', 'extreme')
        ,'choices' => piklist(
          get_posts(array(
            'post_type' => 'post'
            ,'numberposts' => -1
            ,'orderby' => 'title'
            ,'order' => 'ASC'
          ))
          ,array('ID', 'post_title')
        )
        ,'relate' => array(
          'scope' => 'post'
        )
      ));
    • #4639
      justin
      Member

      I copied the form above exactly and it is doing the same thing.

      I attached a screenshot of what it looks like after I change the value, but it seems to be a problem with the meta_key not being deleted from the related post.

      Here is my entire meta-box:

      <?php
      /*
      Title: User Registration
      Post Type: trip_reg
      */
      
      piklist('field', array(
              'type' => 'select'
              ,'field' => 'reg_user'
      		,'label' => __('Person', 'Extreme')
      		,'value' => '0' // Sets default to None
      		,'description' => __('Please select your spouse below', 'Extreme')
      		,'choices' => array( 0 => "Select User" ) + piklist(
      						get_users(
      							array(
      								'orderby' => 'display_name'
      								,'order' => 'asc'
      							)
      							,'objects'
      						)
      						,array(
      							'ID'
      							,'display_name'
      						)
      						)
            )); 
      
      	   piklist('field', array(
        'type' => 'select'
        ,'field' => '_' . piklist::$prefix . 'relate_post'
        ,'label' => __('Mission Trip', 'extreme')
        ,'choices' => piklist(
          get_posts(array(
            'post_type' => 'post'
            ,'numberposts' => -1
            ,'orderby' => 'title'
            ,'order' => 'ASC'
          ))
          ,array('ID', 'post_title')
        )
        ,'relate' => array(
          'scope' => 'post'
        )
      ));
      	  piklist('field', array(
              'type' => 'select'
              ,'field' => 'reg_mobi'
      		,'label' => 'Mobilizer'
      		,'value' => '0' // Sets default to None
      		,'description' => 'Please select your Mobilizer below'
      		,'choices' => array("None" => "None" ) + piklist(
      						get_users(
      							array(
      								'role' => 'aamrole_5584794554851'
      								,'orderby' => 'display_name'
      								,'order' => 'asc'
      							)
      							,'objects'
      						)
      						,array(
      							'ID'
      							,'display_name'
      						)
      						)
            )); 
      piklist('field', array(
      'type' => 'radio'
      ,'field' => 'shirt_size'
      ,'value' => 'Large' // Sets default to large
      ,'label' => 'T-Shirt Size'
      ,'choices' => array(
        'Small' => 'Small'
        ,'Medium' => 'Medium'
        ,'Large' => 'Large'
        ,'XLarge' => 'XLarge'
      )
      ));
      
      piklist('field', array(
      'type' => 'radio'
      ,'field' => 'reg_basic_form'
      ,'value' => 'False' // Sets default to large
      ,'label' => 'Basic Form Completed'
      ,'choices' => array(
        'True' => 'True'
        ,'False' => 'False'
      )
      ));
      
      piklist('field', array(
      'type' => 'radio'
      ,'field' => 'reg_medical'
      ,'value' => 'False' // Sets default to large
      ,'label' => 'Medical Form Completed'
      ,'choices' => array(
        'True' => 'True'
        ,'False' => 'False'
      )
      ));
      
      ?>
Viewing 5 reply threads
  • You must be logged in to reply to this topic.