[development] FAPI and _display hook
Ivan Sergio Borgonovo
mail at webthatworks.it
Thu Feb 7 11:17:18 UTC 2008
On Thu, 7 Feb 2008 10:30:12 +0100
"emanuele quinto" <emanuele.quinto at gmail.com> wrote:
> On the _validate you can do whatever you want: save values with
> set_variable or global variable (I know, I know...) or in a table.
> In principle you don't have to wait the _submit.
Yep... but somehow you're just making a copy (a global one) of
something that should be already there and accessible as much as
FAPI does a lot of valuable work that is hard to take out unless you
use some not really clean technique that mix form processing,
rendering and stuff related to value passing.
> > At the end of drupal_get_form $form_values/status should be fully
> > populated so you could access it through such a global...
> $form_status['values'] is populated (in D6):
> * if you set $form_status['rebuild'] (in _validate)
> * if you set some value in $form_status['storage']
> They are available in a _form_alter hook where you can change the
> apparence of the form.
Somehow... in this use case... form is gone, it already finished its
task, it checked for spoofing, filled and validated the submitted
data and they are in $form_status.
All these techniques look like getting in the FAPI from the back door
to steal what you need and make it available to other parts of your
eg. I could just write a function that get called from whatever hook
FAPI is going to call that call another function with a static
member to take a snapshot of $form_status and then I can call the same
helper function to get back a copy of the $form_status... but still,
that's like stealing, not asking.
Of course this doesn't solve the problem to know when $form_status is
ready... that's why we have hooks... etc... etc...
Every module writer could do the same and we will end up with 20
copies of $form_status and 20 similar thief functions.
I don't think that using validated data without pushing them to the
DB or session in more than one place is something unusual.
Maybe part of drupal_get_form could become a sort of hook that
process $_POST before anything else get called, you could book $_POST
processing in menu hook and drupal_get_form should just render the
form.... but well this looks pretty radical and maybe completely
wrong since I don't know enough about FAPI internals.
Ivan Sergio Borgonovo
More information about the development