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.
Compact Forms reacts to a $form['#compact_forms'] = FALSE;
allowing you to disable compact forms from with a module's hook_form_alter. I would like to be able to do this from within the theme layer, in mytheme_preprocess_form()
.
However, mytheme_preprocess_form() gets called after compact_forms_form_alter(), and so setting #compact_forms to FALSE there has no effect.
Comments
Comment #1
mrfelton CreditAttribution: mrfelton commentedIn fact, according to #591794: Allow themes to alter forms and page themes can now implement hook_form_alter too. However, this doesn't always work when trying to disable compact forms, since there is no guarantee that my hook_form_alter will run before compact_form's.
Perhaps compact forms should set itself a high module weight, to increase the likelihood of being called after other modules / themes hook_form_alter implementations?
Comment #2
mrfelton CreditAttribution: mrfelton commentedActually, theme implementations of hook_form_alter always run after modules, so adjusting the weight would make no difference.