Women in Technology

Hear us Roar



Article:
  Getting Started with PHP's HTML_QuickForm
Subject:   addFormRule callback
Date:   2006-12-05 17:52:06
From:   hemoglobina
If you are working with HTML_QuickForm from inside another function, callbacks do not work in the same way. I mean calling:
$form->addFormRule( "newcontact_validate" );
won't work due to scope issues.
Does anyone know how to setup the callback from inside another class?
At first I thought about doing it like this:
$form->addFormRule( "$this->newcontact_validate" );
but it did not work... I'm lost on this one.
Thanks!
Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • addFormRule callback
    2007-04-28 05:07:04  rzygler [View]

    To setup a callback from inside another class, you need to make the form a global var. So, in the calling class, you would start it with:

    global $form

    and then create the form from there. Then in the callback class method, you again use:

    global $form

    and you can reference the methods/elements of the form.