turn Mb Relationships as Field and make 1 to many relationships

Support MB Relationships turn Mb Relationships as Field and make 1 to many relationships

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #10610
    KwangGanKwangGan
    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 😀

    #10617
    Anh TranAnh Tran
    Keymaster

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

    #10620
    KwangGanKwangGan
    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 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.