CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Webform: Create a Household for an Individual Without Specifically Asking User
Pages: [1]

Author Topic: Webform: Create a Household for an Individual Without Specifically Asking User  (Read 1275 times)

PrincessAng417

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 2
  • CiviCRM version: 4.5.4
  • CMS version: Drupal 7.34
Webform: Create a Household for an Individual Without Specifically Asking User
November 07, 2012, 06:52:28 am
I am using Webform to process an application request using CiviCase.

I would like to prompt the user for his/her name and automatically create a Household to assign my Individual to.

My approach was to create an Individual contact and a  Household contact.

I want the name of the Household to be the last name of the Individual concatenated with the word "Family".  I don't want to ask the user to fill out the Household Name field.

For instance, my user enters his first name and last name, "John" and "Smith".

Without the user being aware, I want to create a Household called "Smith Family" and create the relationship with the Individual.

Am I on the right track?  What would I need to do to create the Household in this manner?  Do I need Rules or Webform Conditional, or some other solution...?

Thanks in advance!
Angela

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Webform: Create a Household for an Individual Without Specifically Asking User
November 16, 2012, 09:34:00 am
Hi Angela. Here's what I would do:
1) Set up the household contact for the webform the normal way. Add houesehold name field and also existing contact field (widget: static, hidden) for the household. The individual should be contact 1. The household can be contact 2.
2) Be sure to create the relationship. Also make sure the "existing contact" field is set up to autofill the household based on that relationship. This will make updates possible.
3) Test your form by manually entring a name for the household and make sure everything actually works.
4) Now you just need a tiny bit of jQuery to hide the household name field and fill it. Easiest way to get that onto your page is with a custom markup field in the webform.
Try asking your question on the new CiviCRM help site.

PrincessAng417

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 2
  • CiviCRM version: 4.5.4
  • CMS version: Drupal 7.34
Re: Webform: Create a Household for an Individual Without Specifically Asking User
December 19, 2012, 10:50:07 am
Thanks so much for your help!

I've gotten through most of the steps now... and it works!  And... uh...

"Now you just need a tiny bit of jQuery to hide the household name field and fill it." 

I guess I need a tiny bit of jQuery?  I guess the good news is it's not a whole lot of jQuery?   ;)

Can you point me in the right direction to start?  My Google search abilities are failing me.  :'(

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Webform: Create a Household for an Individual Without Specifically Asking User
December 19, 2012, 11:09:33 am
Can you provide a link to your form?
Try asking your question on the new CiviCRM help site.

PrincessAng417

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 2
  • CiviCRM version: 4.5.4
  • CMS version: Drupal 7.34
Re: Webform: Create a Household for an Individual Without Specifically Asking User
December 19, 2012, 12:02:14 pm
Unfortunately, I am working on a development server behind the walls of an intranet. 

Can I provide screenshots or some other information?

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Webform: Create a Household for an Individual Without Specifically Asking User
December 19, 2012, 12:09:38 pm
Please right-click the household name field and "inspect element with firebug" and post a screenshot
Try asking your question on the new CiviCRM help site.

PrincessAng417

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 2
  • CiviCRM version: 4.5.4
  • CMS version: Drupal 7.34
Re: Webform: Create a Household for an Individual Without Specifically Asking User
December 21, 2012, 07:58:27 am
I hope this provides what you're asking for.  Thank you so much for taking a look.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Webform: Create a Household for an Individual Without Specifically Asking User
December 21, 2012, 03:30:03 pm
Well I do recommend you start reading more about jQuery because it is really quite easy to learn and you can't always rely on getting other people to write this stuff for you. The basic format is $('some-selector).someAction();

For your immediate problem, just create a new webform component type markup, and paste this in (be sure you are using an input format that does not strip any tags)

<script type="text/javascript">
(function($) {
  $('input[name*=1_contact_last_name]').keyup(function() {
    var name = $(this).val() + ' Family';
    $('input[name*=household_name]').val(name);
  }).keyup();
})(jQuery);
</script>

Confirm that's working, and you can then edit your household name field and change it's widget to "hidden" (be sure to NOT set hidden type to "secure value" since you need to allow this to be altered). You should also be able to edit the household "existing contact" field to make that hidden as well.
Try asking your question on the new CiviCRM help site.

PrincessAng417

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 2
  • CiviCRM version: 4.5.4
  • CMS version: Drupal 7.34
Re: Webform: Create a Household for an Individual Without Specifically Asking User
December 26, 2012, 10:26:10 am
Thank you so much!  It works, and I couldn't be happier!

Is there a specific resource you would recommend to start with for learning jQuery?  I was thinking about Codecademy.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Webform: Create a Household for an Individual Without Specifically Asking User

This forum was archived on 2017-11-26.