• Resolved Eduardo Cheis

    (@eduardocheis)


    I have a WordPress site in a local server that uses Pods to create custom fields. It’s a genealogical website and what i am trying to achieve is the following:
    I a have a parent Pod called baptism used to create a post to register (lets say) someone called Antonio. From that parent post i can create child posts of Antonio’s relatives using a Pod named baptizand_relative.
    I have relation fields on both pods to link the two pods, but I would like that the relation field in the child post to be automatically populated with the related parent post (so that it would not have to be filled in manually by the user)

    Settings of the concerned fields
    Parent Pod: ‘baptism’
    Name: ‘people_related_to_baptizand’
    Field type: Relationship
    Related Type: Relatives (baptizand_relative)
    Bi-directional Field: Relatives of the baptizand (relative_to_the_baptizand) [Pod: baptizand_relative]

    Chlid Pod: ‘baptizand_relative’
    Name: relative_to_the_baptizand
    Field type: Relationship
    Related Type: Baptisms (baptism)
    Bi-directional Field: Add person mentioned in the record (people_related_to_baptizand) [Pod: baptism]

    In short when I create a post for a baptized person named Antonio, I can then add other people mentioned in the record. Let say the godfather was Joseph.
    When I add Joseph from the parent post I will have to manually fill the field relative_to_the_baptizand with the related parent post Antonio. I would like this to be auto-populated with the corresponding parent post to avoid mistakes (this is especially important because there will be a lot of people with the same name, making it very difficult to manually insert the wright info.

    I am fairly new to the world of Pods so please bear this in mind when providing you much welcome support.

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Plugin Support Paul Clark

    (@pdclark)

    If I create a baptism titled Antonio, then add Joseph to bi-directional relationship field people_related_to_baptizand, save both, then open Joseph, people_related_to_baptizand is automatically populated with Antonio. This is how bi-directional fields work.

    If that functionality is not occurring, please check that the appropriate Bi-directional Field is set in the settings for each field.

    If Antonio is a different Pod, such as person instead of baptism, or there is another workflow occurring other than creating starting from creating a baptism in wp-admin, then adding Joseph from the people_related_to_baptizand field, please feel free to elaborate on the workflow.

    If some other functionality is desired, such as validation or population of a field based on another field, please see examples for https://docs.pods.io/code/action-reference/pods_api_post_save_pod_item_podname/, where the action pods_api_post_save_pod_item_baptism would run when baptism is saved, and pods_api_post_save_pod_item_baptizand_relative would run when baptizand_relative is saved.

    If error_log( print_r( $pieces, true ) ); is placed inside a function attached to either action, the content of all fields, such as IDs of posts in the relationship fields will be written to the PHP error log.

Viewing 1 replies (of 1 total)
  • The topic ‘Auto Populate Relationship Field’ is closed to new replies.