Score:1

Place field in "Url Alias" advanced group section (path-0)

jp flag

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

beltouche avatar
cn flag
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.
Bohus Ulrych avatar
jp flag
Actually yes. My module has weight 1002 - and is last one.
Score:1
cn flag

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';
Bohus Ulrych avatar
jp flag
Brilliant! Thanks @Clive.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.