The current code adds the after_build callback to all forms but it should only add it to node forms.

Comments

mastoll’s picture

@rooby,

You identify three code issues with the latest dev version of this module. Can you suggest alternative coding?

i.e., here, how would you alter the code so that it selectively adds the after_build callback only to node forms and not to all forms?

N30’s picture

@mastoll

You add $form[after_build] under and if statement like this.

if($form['#entity_type' == 'node']){
   $form['#after_build'][] = 'after_build_custom_function';
}

You can add different "after_build" function based on your form.

kopeboy’s picture

Can we have a patch please?

I am just a site builder and this functionality is very important for multilingual sites..

rooby’s picture

Status: Active » Needs review
StatusFileSize
new576 bytes

This should do it.
It uses hook_form_BASE_FORM_ID_alter() to just alter node forms.

another way is to use the $form_id variable from hook_form_alter() but that is a little messier in this case.