1

I'm trying to place my node field to the Advanced group - URL alias section. I'm doing it in custom hook_form_BASE_FORM_ID_alter(), where I'm trying to set custom #group like this:

$form['my_filed']['#group'] = 'path-0';

But "path-0" neither "path_0", "path" works. But if I use something else e.g. "meta", "menu" ... then my field is displayed in right place. What's the trick to place it in "Url Alias"? Thanks

2
  • Have you tried playing with the module's weight? I've seen something like this before where my custom module's hook is running before that group even exists. If you increase the module's weight, you can ensure it runs after the group is created.
    – beltouche
    Nov 11, 2021 at 16:43
  • Actually yes. My module has weight 1002 - and is last one. Nov 11, 2021 at 17:01

1 Answer 1

1

It's not all that obvious unless you look at the code which processes the form, but you can use the ][ separator, which the general form API uses to denote a parent/child relationship in a string.

This works for me:

$form['field_foo']['#group'] = 'path][0';
1
  • Brilliant! Thanks @Clive. Nov 12, 2021 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.