Download & Extend

non-object error message when running drush

Project:Custom Node Template
Version:6.x-1.5
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

I was getting the following error message when I ran drush:
WD php: Notice: Undefined index: #node in custom_node_template_form_alter() (line 100 of
/var/www/sites/all/modules/contrib/custom_node_template/custom_node_template.module).

This may only be a php 5.3 problem but here's a suggested fix. Also, attached as a patch file.

diff --git a/custom_node_template.module b/custom_node_template.module
index 3dfdd59..ec4b3f1 100755
--- a/custom_node_template.module
+++ b/custom_node_template.module
@@ -97,7 +97,9 @@ function custom_node_template_node_type($op, $info) {
*/
function custom_node_template_form_alter(&$form, $form_state, $form_id) {
drupal_add_css(drupal_get_path('module', 'custom_node_template') .'/custom_node_template.css');
- if ($form['#node']->type .'_node_form' == $form_id) {
+ $formtype = '';
+ if(isset($form['#node'])){$formtype = $form['#node']->type.'_node_form';}
+ if ($formtype == $form_id) {
$form['nodetemplate'] = array(
'#type' => 'fieldset',
'#title' => t('Node template settings'),

AttachmentSize
custom_node_template.patch719 bytes
nobody click here