FormAPI 3: State of the Union
The FormAPI 3 patch that landed early this month has added some significant capabilities to the API and smoothed out rough edges that have been around since Drupal 4.7. With the code freeze 4 weeks off we have a bit more breathing space, and I wanted to give folks a heads up on a small handful of high-importance FAPI patches that are still in the queue. http://drupal.org/node/121620 This patch takes some of the hard-coded logic in form_builder() -- the stuff that handles how form elements are populated from incoming $_POST values -- and allows each form element type to implement custom handling code in a function, not unlike the submit and validate functions. This sounds simple, but is a BIG advance towards simplification of CCK fields and custom element types. http://drupal.org/node/146187 We've long juggled $_POST and $form_values when dealing with forms. This patch ensures that the raw post data is stored in $form_state in addition to the finessed $form_values. It also clarifies one of the tricky bits about drupal_execute() -- although it currently *says* that it takes a form values collection for processing, it REALLY treats that passed-in data like raw post values. With some complex forms, this causes odd issues. After this patch, drupal_execute() operates on $form_state['post'] for greater clarity. http://drupal.org/node/146667 This patch is ginormous, but implements a very simple pair of changes. First, $form_state should always be the FIRST parameter for a form building function, rather than the LAST. Without this change, form building code triggered via a menu callback will break if bogus parameters are passed in after the normal path. In addition, it eliminates the legacy $form_values variable, and points people instead to always use the standard, always-available $form_state ['values'] data. Reviews and testing are appreciated; the quest to streamline the API continues. Hoorah! --Jeff Eaton
On 01 Jun 2007, at 06:18, Jeff Eaton wrote:
The FormAPI 3 patch that landed early this month has added some significant capabilities to the API and smoothed out rough edges that have been around since Drupal 4.7. With the code freeze 4 weeks off we have a bit more breathing space, and I wanted to give folks a heads up on a small handful of high-importance FAPI patches that are still in the queue.
Thanks for this constructive overview. I think we should aim to include all 3 of these patches into Drupal 6. I'm tempted to commit all 3 of these patches later tonight. The code looks ready, they just could do with more testing. If committing these patches breaks a form or two, it should be easy to recover from that over the weekend. (Although, history has learned us that we should be careful with this. ;)) The sooner we can get this in core, the sooner we can move on with the other patches. -- Dries Buytaert :: http://www.buytaert.net/
On Jun 1, 2007, at 6:55 AM, Dries Buytaert wrote:
I'm tempted to commit all 3 of these patches later tonight. The code looks ready, they just could do with more testing. If committing these patches breaks a form or two, it should be easy to recover from that over the weekend. (Although, history has learned us that we should be careful with this. ;))
Well... *I* wouldn't complain. ;-) --Jeff
participants (2)
-
Dries Buytaert -
Jeff Eaton