Support » Plugin: Pods - Custom Content Types and Fields » add/save on a pulldown field

  • Resolved joneiseman


    I want to create and update pod items in code. I can use the pod add and save functions to do that and it works fine for simple fields. However, it doesn’t work for relationship fields. Let’s say the ‘tour’ field is a relationship field and $tour is the post id of the related field and $postid is the post that I’m trying to update (using the save function).

    $data = array( 'tour' => $tour );
    $pod = pods('ride');
    $pod->save( $data, null, $postid);

    The above doesn’t work. What should the format be for the value of a relationship field when doing add or save?

    I’m using a simple uni-directional relationship.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I figured out how to do it. I changed it to the following and now it works:

    $pod = pods('ride');
    $pod->add_to('tour', $tour);

    You need to use remove_from and add_to for relationship fields (instead of add or save).

    Plugin Author Jim True


    Yep, add_to and remove_from since you’re dealing with a relationship field array. I’m glad you figured this one out 😉

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add/save on a pulldown field’ is closed to new replies.