[development] FAPI and _display hook

Ivan Sergio Borgonovo mail at webthatworks.it
Thu Feb 7 08:24:24 UTC 2008


On Wed, 6 Feb 2008 19:49:12 -0600
Larry Garfield <larry at garfieldtech.com> wrote:


> It certainly could.  You could easily theme a table and then stick
> the rendered result in a markup form value, and you're done.

> It has nothing to do with Views, really.  The Theme Wizard is just
> an example of it that I remember writing.  

Thanks.

Emanuele Quinto wrote me about a similar solution for D6 and finally
I had the chance to see View Wizard.

I find this solution convoluted.

At a first sight furthermore putting stuff in #markup will end up in
stuff being nested in <form>.

Anyway this approach incur in another problem... what if your form is
in an area and your results have to be displayed in another and you
still need the form?
OK hook_display won't solve this problem as well but at the end the
problem is that $form_values/$form_status is not available outside
the FAPI while $_POST/$_GET are... but well using $_POST/$_GET means
you're not using FAPI.

I saw some global in FAPI... and well I think somewhere there should
be something like $forms[$form-id].
At the end of drupal_get_form $form_values/status should be fully
populated[1] so you could access it through such a global... but
beside the fact that we would be adding one more global (just
something to reflect on, not a dogma), even if I'd find such kind of
beast in FAPI... it is not documented and not part of the advertised
FAPI. That means that virtually it doesn't exist. Not being
advertised Karoly would be absolutely free to change its name or
structure for a bug fix.
And yeah it's better it doesn't get into the "public" FAPI but I'd be
better to have some king of encapsulated access to
$form_values/status outside drupal_get_form.

FAPI is doing a lot of good work around $_POST that can not easily be
recycled outside of drupal_get_form.
Not only it validate the form but _validate hook can change values,
so that $form_values/status is actually more valuable than $_POST.
And there are other interesting data in $form_values/status too.

Even stuff that use the _submit hook to really save stuff on DB force
you to read the DB to see what was sent from the form.

[1] that actually poses another problem if you need
$form_values/status in more than one place

-- 
Ivan Sergio Borgonovo
http://www.webthatworks.it



More information about the development mailing list