2

I have a site that generates letters to be sent to schools.

The visitor arrives at the front page where they are presented with a map (leaflet map) with all the local schools marked on it. They then can click on a specific school to view its page (node with school location (addressfield) info).

Here they have the option to 'generate a letter to the school' - I have the form (entityform) set up but it needs the visitor to type in the school address again. How can I dynamically fill the address-field in my form based on the school the visitor navigated to the form from?

map>school>school-specific-form

There are over a hundred schools, so would prefer not to have to duplicate my form...

Thanks.

2 Answers 2

1

If you don't want coding, this is one possibility:

If you only have one form, but hundreds of nodes, another way I would suggest to do it is to use Webform Template for the School content type. You can create one webform template and then reuse it for every school node, but the address field in the webform should have a default value that is a token of the node's address field. All you would need to do is set up your webform template's address field to have a default value of something like [node-field-school-address] and every instance of the webform will have the address of the node it belongs to.

In order to use tokens in a webform, you will need this module: Webform Patched . This is a module that contains the Webform module itself along with token support an therefore the original Webform module should be disabled. I implemented this myself for my site and it worked without any problems.

I never worked with addressfield, but I found this module in case you need it: Addressfield tokens

1
  • Hello, thanks for your response. Webform is not viable at the moment, I am using Entity forms ... The addressfield tokens suggestion was useful. Right now I am currently investigating context-aware views to pre-populate my fields. I'll report back here when I've solved the problem. Thanks. Mar 29, 2014 at 2:33
0

Setting the scene:

"School-Info" content type = Fields (email, telephone, address, etc...) + Letter generator

  • I want to pull the values from the already-populated fields of my "School-Info" content type to my 'letter generator'...

  • I did not want the user to have to re-type the school's (addressfield) information into the addressfield of my letter-generator because it's hassle and might discourage them from sending the letter.

  • Therefore my problem was passing the values of a field-type addressfield to an Entityform on the same node... and from there to a pdf of that specific entityform submission.

  • Generating the PDF from my entityform alone and not on a per-page basis helps me manage the generated letters on a per-user basis ... letter response times can be tracked etc...

I did this:

  1. Use views to make a block that displays the addressfield for the particular school - this can be done by setting a contextual filter for the node ID.
  2. Inside the 'letter generator' entity-form type add an entity reference to this view/block.
  3. Done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.