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 »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Remove or change submitted form value
Pages: [1]

Author Topic: Remove or change submitted form value  (Read 614 times)

pminf

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 0
  • CiviCRM version: 4.3
  • CMS version: Drupal 7
  • MySQL version: 5.6
  • PHP version: 5.3
Remove or change submitted form value
September 22, 2014, 03:43:55 am
I'm trying to remove a submitted form value to disable the deletion of a group contact (details here http://forum.civicrm.org/index.php/topic,34179.0.html).

Which hook can be used to accomblish this? I've already tried hook_civicrm_pre, hook_civicrm_validateForm and hook_civicrm_postProcess with no success. I think I have to use hook_civicrm_postProcess but I don't know how to alter submitted values. Can I unset values of the form object to change submitted data? If so, how?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Remove or change submitted form value
September 22, 2014, 02:17:23 pm
I managed to do this recently & added a note to the end of this page

http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_validateForm
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

pminf

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 0
  • CiviCRM version: 4.3
  • CMS version: Drupal 7
  • MySQL version: 5.6
  • PHP version: 5.3
Re: Remove or change submitted form value
September 23, 2014, 08:22:57 am
Cool, so I'm able to update the submitted values. But I still don't know how to prevent the deletion of the group contact.

I've tried to unset the values:
Code: [Select]

$data = &$form->controller->container();
if(! $data['values']['Register']['group'][9]){
   unset($data['values']['Register'][9]);
   unset($data['values']['Register']['group'][9]);
}
...but this results the removal of the contact from the group (here exemplary group with ID 9).

watchdog('myhook_civicrm_validateForm $data', '<pre>'. print_r($data, TRUE) .'</pre>') output:
Code: [Select]
Array
(
    [defaults] => Array
        (
        )

    [constants] => Array
        (
        )

    [values] => Array
        (
            [Register] => Array
                (
                    [qfKey] => 04d4ca7320a3ccab97a78323100d8183_6388
                    [entryURL] => http://example.com/civicrm/event/register?reset=1&id=109
                    [gender_id] => 2
                    [nick_name] => Dr. habil.
                    [first_name] => John
                    [last_name] => Doe
                    [email-Primary] => john.doe@example.com
                    [current_employer] => Dummy Inc.
                    [custom_26] => Web Solutions!
                    [do_not_mail] => 1
                    [custom_43] => Array
                        (
                            [0] => 1
                        )

                    [8] => 1
                    [7] => 1
                    [group] => Array
                        (
                            [8] => 1
                            [7] => 1
                        )

                    [scriptFee] =>
                    [scriptArray] =>
                    [additional_participants] =>
                    [_qf_default] => Register:upload
                    [MAX_FILE_SIZE] => 134217728
                )

            [ThankYou] => Array
                (
                )

        )

    [valid] => Array
        (
            [Register] =>
            [ThankYou] =>
        )

)

pminf

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 0
  • CiviCRM version: 4.3
  • CMS version: Drupal 7
  • MySQL version: 5.6
  • PHP version: 5.3
Re: Remove or change submitted form value
October 09, 2014, 08:15:46 am
I still don't know how to remove a submitted empty group checkbox. If I unset the group value from the controller object, the related group contact will be deleted.

I'm kinda lost here, so I would appreciate any help  :-\

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Remove or change submitted form value

This forum was archived on 2017-11-26.