• Resolved Kir 2012

    (@kir-2012)


    Hi, my apologies if I’ve not been able to find an instance of this having arisen before, I found some similar questions but nothing quite the same that I could use to get to a solution…

    To explain what I’m trying to do with pods just for context, I’m using WCMP plugin (Woocommerce Market Place Multivendor, it runs with Woocommerce), and I’ve added a tab in the vendor dashboard for product vendors to select and display other users of a certain role type on their (CPT) ticket.

    I’ve successfully added the facility for my vendors to choose data for other fields here, which have been created using pods, and displayed them in the ticket, such as to and from dates and image uploads… so I think somewhere along the line I’m perhaps just completely misunderstanding how to use relationships with pods.

    So far, I’ve extended the CPT ‘ticket’ (products, renamed) with a field called whats_onz and made this a relationship field type, relating to users.

    In Relationship Options for that field, selection type is multi select as I’d like a vendor to choose multiple other users to display on their product.

    I’ve chosen list view so that I can display the avatar (guessing that’s what’s meant by icon?)

    In Display Field in Selection List I’ve got {@user_nicename}

    So what I’m trying to achieve, is a multi-select box in the dashboard where users can choose from a list of users, and they will all appear listed on their ticket with an avatar and their username.

    Here’s the wcmp code just for getting the tab content up there, which all works fine as usual, but I need to find what I should be including in here to create that relationship pods multi select form.

    I’ve looked through the documentation and support but I can’t seem to work it out, here’s the code –

    <?php 
    function add_custom_product_data_contents( $pro_class_obj, $product, $post ) {
        //prnt_r($product->get_id());die;
        $hh = get_post_meta($product->get_id() , 'whats_onz' );
        //print_r($hh);
       ?>
    
       
          <div role="tabpanel" class="tab-pane fade" id="see-more"> <!-- just make sure tabpanel id should replace with your added tab target -->
           <div class="row-padding">
    
    //what should I do here to search for users?          
     <div class="form-group">
                   <label class="control-label col-sm-3 col-md-3">More:</label>
                   <div class="col-mzd-6 col-sm-9">
                       <input type="search" name="whats_onz" class="form-control" value= <?php print_r($hh[0]) ?> />
                 
                    
                   </div>
               </div>
           </div>
       </div>
       <?php
    }
    add_action( 'wcmp_product_tabs_content', 'add_custom_product_data_contents', 10, 3 );

    Thanks so much for any help,
    Kind regards

Viewing 3 replies - 16 through 18 (of 18 total)
  • Thread Starter Kir 2012

    (@kir-2012)

    I”m also now trying to add the form by using do_shortcode, like this:

    echo do_shortcode( ‘ [pods template=”form”] ‘ );?>

    – in my php template for the dashboard that my users use to edit products, calling a pods template, in which I have a form shortcode:

    [pods form=”1″ name=”product” fields=”whats_onz” not_found=”Nothing saved here yet…”]

    But unfortunately I’m still getting the same result, the form is appearing as I would expect to see it, and I can choose from users, but there is a perpetual spinning loader and error message which comes up from the start (ie before I submit anything, in this case) above the form, to say: “Content, title, and excerpt are empty.”

    I can select options but they do not save. It works fine in the back end though.

    Can you think of anything that could be causing this? I’d love to get it working!

    Kind regards
    K

    Thread Starter Kir 2012

    (@kir-2012)

    I looked at this thread about similar:
    https://github.com/pods-framework/pods/issues/2295

    ….and I wonder should I be adding into the mix some other fields, but hidden somehow, if there’s a need to submit a post title, excerpt or content in a form?

    Thread Starter Kir 2012

    (@kir-2012)

    This seems to be resolved now! Here’s what worked for me ??
    Thank you!

    $pods = pods( 'product', $product->ID );
    // Specify which fields to show.
    $params = array( 'fields_only' => true, 'fields' => array('whats_onz') );
    // Output the form.
    echo $pods->form( $params );
    
    
Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Searching CPT Tickets related field in form front end’ is closed to new replies.