Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#1 | fix_undefined_index-2422639-1.patch | 510 bytes | formatC'vt |
Screenshot at 2015-02-09 12:02:06.png | 67.66 KB | formatC'vt |
Comments
Comment #1
formatC'vt CreditAttribution: formatC'vt commentedPatch fix this error. Just replace
!isset
toempty
and check for#format
.Comment #2
formatC'vt CreditAttribution: formatC'vt commentedthis is easy to reproduce with nodechanges 7.x-1.0-beta5 they have a
in
nodechanges_form_alter()
functionComment #3
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedI think this is included in the latest dev.
Comment #4
formatC'vt CreditAttribution: formatC'vt commentedno, this is not included in the latest dev.