• I have a structure where certain participants are a lead member for an organization and fill out additional fields. I am looking for a way to set their responses to these fields as the default value for the non-lead members for the organization. I have a field set-up where we input the record ID of the lead member (called Parent ID) in the other participants forms.

    Is there a way to call the field on the lead member’s form to set it as a default value for the non-lead members using the parent ID field? Or, if you have another approach you think that could work it would be much appreciated.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author xnau webdesign

    (@xnau)

    There are two approaches to getting this done, and which one you need to use depends on whether the parent ID is always available when the form for the team member is getting shown.

    In both cases you’ll need to use a custom template so that you can set the default values. If you’ve got the parent ID, this is easier, you would load the values of the parent record, then use them to set the defaults for those fields.

    The example on the page explaining how to set up the custom template provides the basic method for checking the field name and altering the targeted fields while laying out the form.

    If the parent ID is not known when the form is shown (such as if the user needs to select it) it’s a bit more complicated, you’ll need to add javascript to bring in the values from the parent record using an AJAX call and then set the defaults on the client side.

    Thread Starter aml608

    (@aml608)

    Thanks for the response.

    We have it set-up right now where the parent ID is entered in by an admin into a hidden field called Parent ID. Is there a way to set the default value of a field in the Manage Fields section to call the result of the parent’s record value. For example, in one of your tutorials you have $current_user->user_login which sets the default to the user’s login. Is there something like “$object_of_parent->field” that can be set as the default to pass the info?

    Basically, looking to have these values passed to the user records after they have already filled out their form. So doing it through the admin side is what I’m trying to achieve.

    Plugin Author xnau webdesign

    (@xnau)

    OK, that is a very different scenario, but not too difficult. You just need some custom code that adds this extra information in when the record is created or saved. There is a filter that lets you modify the values of the record before it is saved or updated.

    Your code just needs to be a filter callback placed on the ‘pdb-before_submit_signup’ or ‘pdb-before_submit_update’ filters. You’d include the fields that need to get the parent record info as hidden fields, then set the value of those fields in your filter.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Passing Data to Another User’s Form’ is closed to new replies.