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.
I build a custom form:
function zzb_askquestion_form(form, form_state) {
try {
form.elements['title'] = {
type: 'textfield',
title: 'Title',
required: true
};
form.elements['body1'] = {
title: 'Question descrition',
type: 'textarea',
};
form.elements['submit'] = {
type: 'submit',
value: 'Save'
};
return form;
}
catch (error) { console.log('zzb_askquestion_form - ' + error); }
}
it works correctly,
if I change "body1" to "body":
function zzb_askquestion_form(form, form_state) {
try {
form.elements['title'] = {
type: 'textfield',
title: 'Title',
required: true
};
form.elements['body'] = {
title: 'Question descrition',
type: 'textarea',
};
form.elements['submit'] = {
type: 'submit',
value: 'Save'
};
return form;
}
catch (error) { console.log('zzb_askquestion_form - ' + error); }
}
I get a "UNDEFINED" message, the form does no display.
Comments
Comment #1
tyler.frankenstein CreditAttribution: tyler.frankenstein commentedPlease send a screen shot and/or a copy/paste of the console.log() message(s) that show the "undefined" message.
Either way, very strange. I don't see why body vs body1 would cause any problems.