If you try to add programmatically form element with type "text_format" (https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.h...) you will get an error

Notice: Undefined index: format in ckeditor_pre_render_text_format() (line 304 of /var/www/drupal-latest/sites/all/modules/ckeditor/ckeditor.module).

This is because format value filled by D7 core with empty array, and format type stored in #format (look at screenshot).

this is easy to reproduce with nodechanges 7.x-1.0-beta5 they have a

    $form['nodechanges_comment_body'] = array(
      '#type' => 'text_format',
      // TODO: should we harvest the label from the comment bundle?
      '#title' => t('Comment'),
      '#description' => t('Provide an explanation of the changes you are making. This will be used for an auto-generated comment about your edit, and will help others understand your motivations.'),
      '#rows' => 5,
      '#weight' => 100,
      '#required' => FALSE, // TODO: should there be times this is required?
    );

in nodechanges_form_alter() function

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

formatC'vt’s picture

Status: Active » Needs review
FileSize
510 bytes

Patch fix this error. Just replace !isset to empty and check for #format.

formatC'vt’s picture

Issue summary: View changes

this is easy to reproduce with nodechanges 7.x-1.0-beta5 they have a

    $form['nodechanges_comment_body'] = array(
      '#type' => 'text_format',
      // TODO: should we harvest the label from the comment bundle?
      '#title' => t('Comment'),
      '#description' => t('Provide an explanation of the changes you are making. This will be used for an auto-generated comment about your edit, and will help others understand your motivations.'),
      '#rows' => 5,
      '#weight' => 100,
      '#required' => FALSE, // TODO: should there be times this is required?
    );

in nodechanges_form_alter() function

SocialNicheGuru’s picture

I think this is included in the latest dev.

formatC'vt’s picture

no, this is not included in the latest dev.