Hi,

I am keen to use the jEditable module in my site to update date information inline. The current jEditable implementation just does a node_save, bypassing all of the validation checks performed during a normal node edit. However, jEditable has lots of potential for mainstream use.

jEditable should trigger form processing as per a normal form submission. To emulate this there is the drupal_execute() method, which when implemented in jEditable for Datetime fields looks like this:

       if($field['type'] == 'datetime') {
          module_load_include('inc', 'node', 'node.pages');
          $field_name = $field['field_name'];

          $form_state = array();
          $form_state['values'][$field_name][0]['value']['date'] = $value;
          $form_state['values']['op'] = t('Save');

          $form_id = $node->type . '_node_form';
          drupal_execute($form_id, &$form_state, (object)$node);
        }

This works perfectly fine. However, if I create a node type with two Date fields, one of which is mandatory, I get the following errors:

    warning: date_offset_get() expects parameter 1 to be DateTime, null given in /usr/local/apache2/htdocs/drupal6/sites/all/modules/date/date/date_elements.inc on line 490.
    warning: date_format() expects parameter 1 to be DateTime, null given in /usr/local/apache2/htdocs/drupal6/sites/all/modules/date/date/date_elements.inc on line 493.
    warning: date_format() expects parameter 1 to be DateTime, null given in /usr/local/apache2/htdocs/drupal6/sites/all/modules/date/date/date_elements.inc on line 494.
    warning: date_offset_get() expects parameter 1 to be DateTime, null given in /usr/local/apache2/htdocs/drupal6/sites/all/modules/date/date/date_elements.inc on line 495.
    warning: date_timezone_set() expects parameter 1 to be DateTime, null given in /usr/local/apache2/htdocs/drupal6/sites/all/modules/date/date/date_elements.inc on line 496.
    warning: date_timezone_set() expects parameter 1 to be DateTime, null given in /usr/local/apache2/htdocs/drupal6/sites/all/modules/date/date/date_elements.inc on line 497.
    warning: date_format() expects parameter 1 to be DateTime, null given in /usr/local/apache2/htdocs/drupal6/sites/all/modules/date/date/date_elements.inc on line 498.
    warning: date_format() expects parameter 1 to be DateTime, null given in /usr/local/apache2/htdocs/drupal6/sites/all/modules/date/date/date_elements.inc on line 499.

I have done quite a bit of troubleshooting on the problem above and it basically comes down to the way '#value' array is constructed when passing the $element to date_popup_input_value(). But before we get into the nitty gritties...

Reading the issue list, this type of error occurs during node imports and drupal_execute()s and KarenS recommends (http://drupal.org/node/447998#comment-1532746) using node_save() instead of drupal_execute() due to a number of issues.

So, to summarize, jEditable is doing stuff that requires form validation without a form, therefore the only way to do this as far as I can see is with drupal_execute. So my question is, is jEditable + drupal_execute() the correct approach for inline editing and if so, can bugs like the one above be fixed?

/Kevin

Comments

damienmckenna’s picture

Status: Active » Closed (won't fix)

Unfortunately the Drupal 6 version of the Date module is no longer supported. That said, we appreciate that you took time to work on this issue. Should this request still be relevant for Drupal 7 please feel free to reopen it. Thank you.