Visual Form Alter

I recently found a thread on Reddit asking how to update the description field of a specific form. I would usually solve this myself by doing a module. When the thread was not answered for a long time for some reason I started Googling ways to solve this. While there exists some ways to solve the specific question I could not find a single module in Drupal 7 that lets you do a form_alter directly into the system. So I created a module.

So the thread on Reddit can be found here.  And while there are ways to solve this with Markup module, or via translations I could not find a single module that lets you visually edit a form directly via the actual web site. So this morning I sat out on creating one.

Am I bad a Googling/Do I not know module XYZ

So before I will go into details on the module, please let me know if my above claim is not a pretense. I'm not a native english speaker so sometimes I will use the wrong terms while Googling.

If you know of any modules that actually does what this one does please let me know via the contact page or via a comment below and I'll check if my module is really needed/should be merged.

The reason why I am asking is because Drupal 7 is very mature now, so someone should have thought about this earlier?

The Module

So the module is pretty simple. It checks in hook_form_alter for any form elements that are modifiable. It creates a overlay link on these elements that you can click on to redirect you to a form (so a form to edit a form :)).

What kind of form elements you can modify depends on the type of form element. I've just created an associative array that follows the Drupal Form API.

It then saves these values in a big associative array in variables.

Then on form_alter it will check if the form_id and field exists in the variable and if so it will alter the changes. Depending on the field type it will know if the output should be translatable or not.

Simple, simple.

Exporting for performance

So while this might be cool for doing simple changes that might fit the needs of the person in the Reddit thread, this might become cumbersome if you change on many places. The variable that hold all the changes needs to be loaded on every form load that is not cached.

To fix this I also added a functionality to export your data into a module. So a module that creates modules. T-800 here we come!

A word of notice on this though - automated code is all fun and games until someone loses an eye. The different scenarios I have tested the output on looks fine, but installing automated code on a production website without giving it a glance before is really really really not recommended. Specially from a module that is not tested amongst the masses. So use this with care. Please.

Video

Here is a video on how to use it:

Downloading/Testing

The module can be found at https://www.drupal.org/project/visual_form_alter - please try it out if you have the need for it and write up all the bugs you can find so I can fix a stable version.

 

The top picture was shot by AJ Mexico and is shown under CC 2.0 License.