When treefield.module is enabled, it is no longer possible to directly validate creation of non-tree ER fields in the UI.

The problem lies in the fact that the provider selection entry is still being validated as required (#required is TRUE), even though there is no provider to use since the behavior is not being configured, and it has no default value, but is not displayed to the user as long as the behavior is not enabled. Adn the user level, a workaround is to enable the treefield behavior, select a provider, then disable the behavior again.

Code-wise, various possibilites exists:

  • not generating the settings form if the behavior is not enabled: most logical, but then with AJAX regeneration of the form, this may not be properly regenerated if the behavior is reenabled
  • un-requiring the provider: most logical when the behavior is not enabled, but illogical when it is
  • providing a default value for the provider, typically the first value in the list, which luckily happens to be the current best option "nested set". This makes no sense when the behavior is not enabled but does not cause any problem either since the provider hooks are not being fired, and this setting is ignored otherwise.

Weighing the pros and cons, I think the third option is an immediate best, while the first would be a longer-term solution which could be developed when/if the form interactions between the module and its plugins are redesigned.

Comments

fgm’s picture

Status: Active » Needs review
StatusFileSize
new1.91 KB

Patch rolled accordingly.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Agreed with taking the third approach :)

fgm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x-1.x, thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.