After removing an element, form_builder_field_json calls drupal_render on empty $element

te-brian - October 6, 2009 - 21:53
Project:Form Builder
Version:6.x-0.6
Component:Form Builder Core
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

One quick note before I explain the issue:

I posted an issue yesterday, and in implementing the api I plan to post any other bugs or weird things I find. If you're not quite ready for these types of questions just let me know. I don't want to clog up the queue needlessly. Also, I'm not that patch savy, but theres no time like the present to get my hands dirty. If we reach any resolutions and you'd like patches, let me know and I'll see what I can whip up.

Ok now for the current issue.

I was watching the ajax requests while editing my form and noticed some 500s mixed in. I tracked them down to the remove functionality. After calling

form_builder_cache_field_delete($form_type, $form_id, $element_id);

the api tries to print some json output for the field. If my understanding of cache_field_delete() is correct, the field should now be gone, so when form_builder_field_render() is called the element no longer exists.

This causes drupal_render() in form_builder_field_render() (line 647) to receive a NULL element. This leads to a bad call to uasort in common.inc.

To stop the php error for now, I wrapped the drupal_render in an check on the element:

$content = (is_array($element)) ? drupal_render($element) : '';

My real question is, what is the javascript side of the process expecting back from the remove function, and why is it trying to print an element that has been removed from the cache?

 
 

Drupal is a registered trademark of Dries Buytaert.