PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Populate check boxes

  1. When I try to populate checkboxes with these values: array( "text" => get_the_title(), "value" => get_the_ID(), "isSelected" => '', "price" => '' ); and there are less options in the Orginal form specified the checkboxes aren't processed?

    complete function:

    public function fill_combine_order_form($form){
    
    		foreach($form["fields"] as &$field) :
    
    			/*
    			*  Check boxes
    			*
    			*  Author Effectiva internet toepassingen
    			*  @since 0.1
    			*  @created: 8 november 2012
    			*/
    
    			if( $field['inputName'] == 'wp_combined_orders' ){
    
    				// define values
    				$this->combine_order_checkbox_choices = '';
    				$this->combine_order_checkbox_choices = array(); // empty for conflicts
    
    				// check if user has 'orders'
    				$query_args = array(
    					'post_type' => 'orders',
    					'meta_query' => array(
    					   array(
    						   'key' => 'user',
    						   'value' => $_SESSION['user_id'],
    						   'compare' => '=',
    					   ),
    					   array(
    						   'key' => 'status',
    						   'value' => array( 2,3,4 ),
    						   'compare' => 'IN',
    					   )
    				   	),
    					'post_status' => 'publish'
    				);	
    
    				$orders_query = new WP_Query( $query_args );
    
    				if( $orders_query->found_posts >= 1 ){
    
    					while ( $orders_query->have_posts() ) : $orders_query->the_post();
    
    						$this->combine_order_checkbox_choices[] = array( "text" => get_the_title(), "value" => get_the_ID(), "isSelected" => '', "price" => '' );													
    
    					endwhile;
    				}
    				else {
    					$field['type'] = 'html';
    					$field['content'] = '0 orders found';
    				}
    
    				$field['choices'] = $this->combine_order_checkbox_choices;
    
    				//$field['choices'] = $choices;
    				//add_filter("gform_field_value_wp_combined_orders", "populate_checkbox");
    
    			}		
    
    		endforeach;
    
    		$this->form = $form;
    	}
    Posted 9 years ago on Sunday December 16, 2012 | Permalink
  2. Do you have an example of the form online where we can see this functionality?

    Posted 9 years ago on Saturday December 22, 2012 | Permalink