Custom Fields
Re-Envisioned
Support MB Relationships turn Mb Relationships as Field and make 1 to many relationships

This topic contains 2 replies, has 2 voices, and was last updated by  KwangGan 9 months ago.

  • Creator
    Topic
  • #10610

    KwangGan
    Participant

    for this version mb relationships can only implement by add extra php code then plugin pop another metabox for Post edit to connect another object

    but it would be good if this extension can turn into Field Type Like “Post Field” and more options for relationships like

    multiple > false for 1 to many relationships or required field

    thx 😀

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #10617

    Anh Tran
    Keymaster

    Good idea :). I’ll save this idea into my notes.

    #10620

    KwangGan
    Participant

    anyway I want to share my code to make Mb Relationships can select only single value

    in
    "inc/class-mb-relationships-relationship.php"

    search for function

    "parse_meta_box_to"

    put these code under line

    
    $field['name'] = $this->to['meta_box']['field_title'];
    

    like this

    
    $field['name'] = $this->to['meta_box']['field_title'];
    
    $field['clone'] = $this->to['clone'];// <<< option to selective clone on/off
    $field['attributes']['required'] = $this->to['attributes']['required']; // set it required field
    

    now we can use clone = false option

    like this :

    
    'to' => array(
            'object_type' => 'post',
            'post_type'   => 'gallery',
             'admin_column' => 'after title', // THIS!
             'clone' => false, // <<<< add this line for turn off clone 
              'attributes' => array(     // <<< for make field required
            'required' => true,  // <<< for make field required
          ),  // <<< for make field required
            'meta_box'    => array(
                    'context' => 'normal',
            ),
            ),
    
    
Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.