Add meta data to field settings to identify as relationship field

Support MB Relationships Add meta data to field settings to identify as relationship fieldResolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #11883
    Content PilotContent Pilot
    Participant

    I am rolling my own REST API endpoint using some of your code. I want to pick out certain sets of field to include in my endpoint. My main dilemma is that your rest api response shows values for the posts as ID and I need them as the post title. So I am looping through my group fields and also my relationship fields. In the group fields, there is a meta key value to call out the fact that is a group field. In your code you use in_array to accomplish this. Can you add the same meta key to a relationship field? It goes with the stuff like placeholder, name, id, field type, etc. Thank you!

    #12044
    Content PilotContent Pilot
    Participant

    bump

    #12055
    Anh TranAnh Tran
    Keymaster

    Hi Clayton,

    Sorry for the delay. Are you using MB Rest API or you're going to write a custom endpoint?

    I'm not sure how you loop through fields. Can you give more details on that?

    #12082
    Content PilotContent Pilot
    Participant

    I am writing my own endpoint.

    But i don't need help with the rest api. I need a field setting to be added to the Relationship field so I can distinguish it from other fields. I am using rwmb_get_object_fields to get all fields for an object then trying to single out the relationship fields with an in_array of some sorts. I can do this just fine for groups fields since there is a field setting type => group in that array. I would like something similar in the Relationship field. Just one little key value pair since the field_type key is already taken.

    #12121
    Anh TranAnh Tran
    Keymaster

    I got it. Can you try differentiate the relationships fields by ID? Their IDs are always {$rel_id}_from or {$rel_id}_to.

    #12208
    Content PilotContent Pilot
    Participant

    After I found all object fields for a post object. I looped through each field and used this conditional to make sure I was grabbing a relationship field.

    if ( 'post' === $field['type'] && strpos( $field['id'], '_to' ) !== false && strpos( $field['id'], '_from' ) !== false )

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.