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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Adding fields to "Edit Contact Information" screen for related contacts
Pages: [1] 2

Author Topic: Adding fields to "Edit Contact Information" screen for related contacts  (Read 10487 times)

tmcnulty1982

  • Guest
Adding fields to "Edit Contact Information" screen for related contacts
November 24, 2008, 08:08:47 am
Hi,

I just setup site login for all of our members so they can view the contact dashboard, manage their contacts, etc.

I need to allow individuals who have logged in to edit a couple custom fields for their employer organization.  The "Edit Contact Information" screen seems pretty basic and I'm not sure how to extend it in the web interface, e.g., with a Profile.

What's the best way to accomplish what I need?  I started looking at the code for CiviCRM that creates that form to see if I could extend it to include a couple of custom data fields.

First, does this sound like a good approach?  If so, could someone point me to an example of adding custom data fields to a form?  The code is pretty new to me but I think I can figure it out with a good example.

Thanks
Toby

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Adding fields to "Edit Contact Information" screen for related contacts
November 25, 2008, 02:04:02 am
Toby:

Let's say in your case when you create relationship between "Company" and "Employee", there is an option that would allow employee to edit "ALL" details of its "Company".

I am not sure if you can allow editing of only specific fields, like Custom Data.

HTh

Kurund
Found this reply helpful? Support CiviCRM

tmcnulty1982

  • Guest
Re: Adding fields to "Edit Contact Information" screen for related contacts
November 25, 2008, 06:46:44 am
I want to allow the employee to edit all contact details of the organization and, in addition, two custom data fields.  An ideal solution obviously would be to use a profile (or a set thereof) for the editing.

Thanks
Toby

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Adding fields to "Edit Contact Information" screen for related contacts
November 25, 2008, 07:38:20 am

replacing the simple organization information form right now with a profile is the right step forward. its a non-trivial fix, but i can help u get started on IRC :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Adding fields to "Edit Contact Information" screen for related contacts
November 25, 2008, 09:15:07 pm

I was just looking at the code when i realized we added code that allows the editing of profiles using permissioned relationships.

Thus if user A has permissioned relationship on contact id B then for any profile PPP, the url:

q=civicrm/profile/view?reset=1&gid=PPP&id=B
q=civicrm/profile/edit?reset=1&gid=PPP&id=B

will work for user A (and for any user who has edit permission on contact B)

the following steps should work (i tested in 2.2, but am pretty sure should work in 2.1 also)

1. create a profile for the organization (and include your custom fields etc). Let the profile id be PPP

2. Edit CRM/Contact/Page/View/UserDashBoard.php, function links (line 209 or so) and change:

Code: [Select]
                                  CRM_Core_Action::UPDATE  => array(
                                                                    'name'  => ts('Edit Contact Information'),
                                                                    'url'   => 'civicrm/contact/relatedcontact',
                                                                    'qs'    => 'action=update&reset=1&cid=%%cbid%%',
                                                                    'title' => ts('Edit Relationship')
                                                                    ),

TO

Code: [Select]
                                  CRM_Core_Action::UPDATE  => array(
                                                                    'name'  => ts('Edit Contact Information'),
                                                                    'url'   => 'civicrm/profile/edit',
                                                                    'qs'    => 'reset=1&gid=PPP&id=%%cbid%%',
                                                                    'title' => ts('Edit Relationship')
                                                                    ),

let us know if this works :)

lobo


A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

tmcnulty1982

  • Guest
Re: Adding fields to "Edit Contact Information" screen for related contacts
December 11, 2008, 10:09:38 am
That works great.  One caveat: there is a bug that prevents consistent display of profile fields unless they are marked as public.

Also I added the following code instead of replacing the Edit Contact Information link, since I wanted to add to and not just replace its functionality:

Code: [Select]
                                  CRM_Core_Action::UPDATE . '1'  => array(
                                                                    'name'  => ts('Edit Product and Logo'),
                                                                    'url'   => 'civicrm/profile/edit',
                                                                    'qs'    => 'reset=1&gid=21&id=%%cbid%%',
                                                                    'title' => ts('Edit Relationship')
                                                                    ),

I'm not sure if the "CRM_Core_Action::UPDATE . '1'" hack is legit, but it works :)

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Adding fields to "Edit Contact Information" screen for related contacts
August 31, 2009, 04:07:35 am
okay so i am reviving this one as it appears to be the recipe that i have been looking for in discussions here http://forum.civicrm.org/index.php/topic,5186.msg41537.html#msg41537 and several other places

I have set this up on a test and it works fine - I need to test it in some more complex set ups. But if it is good, i would like to add this in relevant wiki page since i haven't found it so easy to find - and while i know there are hook options etc - this pretty well delivers what I have needed on several sites.

So thanks Lobo and Tim
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Adding fields to "Edit Contact Information" screen for related contacts
August 31, 2009, 04:22:03 am
okay spoke a bit soon - the above works grand if there is only one relationship type that might need editing through this route - in most cases I am working around we are needing some 'special contacts' to be able to edit both the company (relationship = employer/ee) and their 'colleagues' (eg relationship 'supervisor/supervisee') - do i put the car in to reverse or shift to all wheel drive?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Adding fields to "Edit Contact Information" screen for related contacts
August 31, 2009, 11:49:42 am

hmm

so why is that a problem? the dashboard should show all the permissioned contacts that you can edit right? and you can do some hook magic to point them to different profiles

lobo

p.s> my memory is a bit hazy on all this, so i might be totally wrong here. ping on irc and we can chat more

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Adding fields to "Edit Contact Information" screen for related contacts
September 01, 2009, 03:18:18 am
Here's one option:

In the php file:

 
Code: [Select]
            CRM_Core_Action::UPDATE  => array(
                                                                    'name'  => ts('Edit Contact Information'),
                                                                    'url'   => 'civicrm/profile/edit',
                                                                    'qs'    => 'reset=1&gid=PPP&id=yycbid%%',
                                                                    'title' => ts('Edit Relationship')
                                                                    ),
Then in the Relationship.tpl file change
Code: [Select]
               <td class="nowrap">{$rel.action|replace:'xx':$rel.id}</td>

To:

Code: [Select]
{* edit URL to link to depending on relationship type - these values are hard coded - ie. 4 = the profile ID*}
{if $rel.civicrm_relationship_type_id eq 2}
{$rel.action|replace:'yy':4}

{elseif $rel.civicrm_relationship_type_id eq 3}
{$rel.action|replace:'yy':5}
{else}
{* default *}
{$rel.action|replace:'yy':6}
{/if}

I would prefer to be able to extend the relationship_type record with an additional custom data field and pass the value of that field through but it looks like the relationship record can be extended but not the relationship type.
« Last Edit: September 01, 2009, 03:54:32 pm by Eileen »
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Adding fields to "Edit Contact Information" screen for related contacts
September 07, 2009, 03:51:06 am
Lobo - any quick thoughts about how checksums would handle taking people to above type Profiles eg relating to an Org that the person is 'permissioned' to access?

If not, I guess I can always try taking them to a 'landing' profile and then see if we can use the 'redirect upon completion' except again I suppose that will require enabling a session.
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Adding fields to "Edit Contact Information" screen for related contacts
September 09, 2009, 04:30:28 pm
And adding to my stream of consciousness here - how about reworking checksum so it can take someone to their Dashboard instead of a Profile?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

johng

  • Guest
Re: Adding fields to "Edit Contact Information" screen for related contacts
June 04, 2010, 07:22:18 pm
This doesn't seem to work for me... it gives me a message that the profile is configured for organization data and I can't use it... is there any workaround for that?

Roland-ST

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 0
Re: Adding fields to "Edit Contact Information" screen for related contacts
August 28, 2010, 10:48:39 am
I've used Lobo solution and insert
this part in
Code: [Select]
CRM_Core_Action::UPDATE  => array(
                                                                    'name'  => ts('Edit Contact Information'),
                                                                    'url'   => 'civicrm/profile/edit',
                                                                    'qs'    => 'reset=1&gid=10&id=%%cbid%%',
                                                                    'title' => ts('Edit Relationship')
                                                                    ),
but i faced a problem. Link opening home page instead of profile, but works perfectly at BackEnd when I add "/administrator" to the link.
Can somebody suggest what is problem with frontend? I use 3.1.5

Roland-ST

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 0
Re: Adding fields to "Edit Contact Information" screen for related contacts
August 28, 2010, 10:52:35 am
I've got error message: You do not have permission to edit this contact record. Contact the site administrator if you need assistance. But I've set permission to edit contact at relationship creation.

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Adding fields to "Edit Contact Information" screen for related contacts

This forum was archived on 2017-11-26.