(I realise the goal is currently to #569094: Get rid of form_set_error(), but as long as it's still around this is something I'd like to see.)
Currently the $name argument of form_set_error() needs to be a string, with nested elements being described as a ']['-separated list.
For the most part, this means imploding your element's '#parents' property. This is then exploded by form_set_error so it can work out what the parents of the element original were.
Given that form_set_error uses the property both in its imploded and exploded form, it would make sense for a developer to be able to provide it as an array (in many cases simply providing the #parents property of the element). form_set_error() would just need to check the argument's type, explode if it's a string and implode if it's an array.
Comments
Comment #12
smustgrave commentedClosing as outdated. Appears form_set_error has been removed from Drupal 9
If you feel it's still an issue please feel free to reopen.