Context: Using the Surveyor for testing.

Currently the user can edit the Form key (machine name) of a field. If duplicated then the user must edit it. This is something I do not like. This is also not nice for non-Latin characters: First, because the value stays empty when using one word only; second, duplicated machine names are probable where just the spaces are replaced by underscores.

There is an issue which requests that non-Latin characters should be transliterated: https://drupal.org/node/1513830. However, I want that it will be something like new_1327593307149 and hidden, non-editable (see https://drupal.org/node/1417746 which actually asks kind of the opposite).

So, what I would like is that the form builder will use the new_1327593307149 value instead of the generated value ("new_grid", for example) AND that it will not be displayed to the user at all - preferable not exist in the form, at all.

Any help here?

Thanks.

Comments

quicksketch’s picture

Hey Amir, nice to see you in the issue queue as well as in my inbox. :)

To solve this problem, you can form_alter the Form Builder form, just like any other form in Drupal. When the form is first created, the Form Builder Webform module intentionally leaves the machine name field empty, so any user-provided value will overwrite the default "new_*" name. If you made this field have a default value, and hid it with #access = FALSE, it would have the functionality you desire. The only downside to this is that it makes configuring any e-mails or confirmation messages that use components rather difficult.

Amir Simantov’s picture

Hi Nate and thanks for the reply.

Yes, your advice is good, of course. if I understand correctly, I can populate the field of the machine name by code using this hook, right?

[Addition, editing]
Well, I may mixed here two different issues. I want changing the logic of the default value (of the machine name) and only then to disable it.

The idea of not hiding it completely is wise :)