Custom Fields
Re-Envisioned
Support General Display element based on 'post'

This topic contains 42 replies, has 3 voices, and was last updated by  carassius 3 years, 8 months ago.

  • Creator
    Topic
  • #1306

    carassius
    Participant

    If I create a basic customer cpt
    name
    phone
    email
    address

    and then in another cpt use ‘type’ => ‘post’ to generate a drop down of names, how can I then filter the other components based on the selected name? Should I use the conditional extension, or is there a way to do this without?

    For example, if someone selects “john doe” I then want the other contact info displayed in input boxes. I hope that makes sense?

Viewing 10 replies - 21 through 30 (of 42 total)
  • Author
    Replies
  • #1352

    carassius
    Participant

    Warning: Illegal string offset ‘title’ in C:\wamp\www\wordpress\wp-content\plugins\project52\plugins\meta-box\inc\meta-box.php on line 343

    Warning: Invalid argument supplied for foreach() in C:\wamp\www\wordpress\wp-content\plugins\project52\plugins\meta-box\inc\meta-box.php on line 386

    Warning: Invalid argument supplied for foreach() in C:\wamp\www\wordpress\wp-content\plugins\project52\plugins\meta-box\inc\meta-box.php on line 150

    #1353

    carassius
    Participant

    Dont mind the errors, it is because I removed the square brackets, but left it as

    // start customer
        $meta_boxes = array(

    instead of

    // start customer
        $meta_box = array(
    #1354

    Tan Nguyen
    Participant

    Oh, sorry, remove the square bracket and keep it $meta_box because I have assign $meta_boxes[] = $meta_box later 😉

    #1355

    carassius
    Participant

    Fixed the errors, but my phone field still doesnt appear

    #1356

    carassius
    Participant

    Ok, the new phone text input area is pulling the correct id: p52_quote_phone_3722 (with 3722 being the select contact post ID), however it is not displaying any value

    #1357

    carassius
    Participant

    here is how I have all my contact metaboxes setup..No boxes appear until I select a name, and then they all become visible under the “New” inputs ie this email

    // Show this email field if match name.
                $meta_box['fields'][] = array(
                    'name'        => 'New Email',
                    'id'      => $prefix . 'email_' . $customer->ID,
                    'type'        => 'text',
                    'std'         => get_post_meta( $customer->ID, 'p52_quote_email', true ),
                    'visible'     => array( $prefix . 'name', $customer->ID ),
                    'columns' => 6
                );

    This is the full contact php

    https://pastebin.com/FSGCMCHJ

    #1358

    carassius
    Participant

    so the question becomes, why is it displaying with no value?

    <input type="text" class="rwmb-text" name="p52_quote_phone_3762" id="p52_quote_phone_3762" value="" placeholder="" size="30">

    #1359

    Tan Nguyen
    Participant

    Can you please check the database (wp_postmeta) to see the records exists here?

    Basically, it grabs value from postmeta table and bind to meta box as I defined in this line:

    
     'std' 		=> get_post_meta( $customer->ID, 'p52_quote_phone', true ),
    

    So if the customer has phone entered, this should be bound to field via std key.

    I’m very happy to see you’re going to the last steps 🙂 This is a great challenge 😀

    #1360

    carassius
    Participant

    yes they are in the database eg

     meta_id: 943
    post_id: 3722
    meta_key: p52_contact_phone
    meta_value: 123456789
    #1361

    carassius
    Participant

    Thanks again for your help!

Viewing 10 replies - 21 through 30 (of 42 total)

The topic ‘Display element based on 'post'’ is closed to new replies.