Contents
* What is scaffolding?
* Forms class scaffolding plug-in features overview
* Current scaffolding plug-in state and live example
* Future features wish list
* Wanted your feedback: try it now!
* What is scaffolding?
Before going to the details of the new plug-in, I think it is better to explain first what is scaffolding for those not familiar with the concept.
In reality, the scaffolding method was not originated in the software development world. It is rather a metaphor inspired on a technique used in the construction of buildings.
It consists of a temporary structure that is put around a building in construction. Its purpose is to help workers do their job of growing the building structure while it is being constructed.
http://en.wikipedia.org/wiki/Scaffolding
The scaffolding metaphor is often used in the software development world. It consists of user interfaces for performing basic application data management operations, such as: Create, Read, Update and Delete (CRUD).
These operations are very frequently used in software applications. That is why there are many tools and libraries to accelerate the construction of scaffolding user interfaces to quickly implement CRUD operations.
The use of scaffolding tools and libraries can dramatically improve the productivity of developers that use them.
Instead of spending a lot of time coding everything manually, developers only have to customize the details of each screen that takes advantage of the scaffolding tools and libraries.
* Forms class scaffolding plug-in features overview
- Complete control of CRUD and other desired operations
The plug-in generates the necessary HTML and Javascript to present forms and listings that correspond to the different states and views of each type of operation.
In the "listing" state it shows a list of records that the user can edit or delete, along with a link to create a new record. The listing may be automatically paginated when it is too long. In the "creating" and "updating" states it shows a form with a new record or an existing record to be edited. In the "deleting" it asks the user if he really wants to delete a record.
Besides the regular CRUD operations, it also supports displaying previews near the forms for creating or updating records. This is meant to let the users see how the record will look like before saving it. Applications have complete control of the generation of previews.
Operations that may change data, like Creating, Updating and Deleting, can also be canceled by the user, obviously with a cancel button.
Each of the operations (Create, Read, Update, Delete, Preview) may be enabled or disabled according to the needs of the application.
- Transparent AJAX support for faster interaction
The plug-in provides transparent AJAX support for several types of operations. This means that forms may be submitted and links may be followed without reloading the page. This way it provides a faster user interface.
If Javascript is not enabled, it will gracefully fallback to non-AJAX based server interactions.
PHP applications using this plug-in do not need to have two sets of code to deal with both AJAX and non-AJAX requests.
Right now, only the preview operation is AJAX-enabled. Other types of operations will also support AJAX interactions soon.
- Integration with arbitrary data source
One of the main requirements of this plug-in is to be flexible. Therefore it does not access to any data source directly. This means that the plug-in itself does not interact directly with databases or any type of source that contains the records of data to be edited.
Instead, it just posts event messages to the application giving the details of each type of interaction. The application just needs to use the forms class GetNextMessage function to retrieve an array with the details of each event.
Several types of event messages may be posted: record created, list records, record updated, record deleted, render preview, etc..
Applications must process these events by storing and retrieving the necessary data from databases or any other type of container they use. Applications may need to pass data back to the plug-in, so it renders the forms or listings depending on what the user is doing.
This approach to separate user interface processing from data storage make things more flexible and simpler to implement. If you are not yet familiar with concept, you will see how simple it may be by looking at the example script mentioned below.
- Customization of the record fields and messages
The forms fields to edit each record are fully customizable. You just need to pass the definition of the fields you need. The plug-in will render them automatically for you.
All the messages displayed as result of the different types of interaction are also customizable. The plug-in provides default texts for each message. You may change the defaults to present more suitable messages, or to translate the messages to the idiom of the user.
* Current scaffolding plug-in state and live example
The scaffolding plug-in has been in development for a while. Now it is almost ready for the first release.
Documentation is not yet ready, but the available example should be sufficient for any developer to take a look at the code and learn from the available examples.
http://www.meta-language.net/forms-examples.html?example=tes ...
This example is a very simple blog editing system. Actually it is a simplified version of the blog publishing system used in the PHP Classes site.
The main script file is named test_scaffolding_input.php . It uses two separate class files named blog_post_model.php and blog_post_view.php .
The first is for implementing operations that store and retrieve data of the blog posts. It just uses PHP session variables as container to store information of the posts being edited. The later is for defining details of presentation of blog posts.
* Future features wish list
- A more customizable presentation template
Currently, the forms and listings are displayed according to a template that is not yet fully customizable. The template will be customizable later after I get some feedback from the users about whether the plug-in displays separately all the necessary elements that may be susceptible of customization.
- Paginated forms and form layout customizations
Currently all form fields are laid out with the vertical auto layout plug-in. If you have records with many fields to be edited, it would be nice to allow splitting the fields over several pages using the paged layout plug-in.
Would these layout options be sufficient? What other forms of layout would you like to have?
- Save and continue editing
Sometimes the users are working on something that may take a while to edit. It would be good to save the current work once in a while to prevent loosing what was done so far, in case of power failure or browser crash.
Currently, the plug-in allows saving the current record but exits the editing mode. It would be better if there was an additional button to just save but continue editing.
I am not sure how to call such new button. Maybe it could be called "Save and continue" to make it different of the current "Save" button. Alternatively, I could rename the "Save" button to "Submit" and name the new button just "Save". What do you think?
- Auto-save
Another nice feature would be to have the option to make the form be automatically submitted once in a while, so the user does not have to remember to do it by himself in order to prevent loosing work.
Several questions need to be decided. For instance, how often should be the form saved?
Shall it be done on regular intervals?
Shall it be done a few seconds after certain fields are changed?
Shall there be a check box to let the user disable auto-save?
- Secure submit buttons
Many sites with forms are vulnerable to CSRF attacks (Cross-Site Request Forgery).
These attacks can make the users perform unintended actions in sites they are already logged in. I already mentioned these attacks in this past article:
http://www.phpclasses.org/blog/post/65-8-defensive-programmi ...
The forms class package comes with the secure submit plug-in to avoid such attacks.
In some cases it would be nice to use secure submit buttons instead of regular ones for actions that may affect stored data like saving and deleting records.
* Wanted your feedback: try it now!
As you may have read above, there are certain issues to be decided. Some decisions may require changes in the implementation of the plug-in that would be backwards incompatible. So, those changes need to be done before the first public release.
Therefore, I would like that you could try the plug-in now and provide feedback to help deciding these and other issues that you may recall.
For now, it would be nice if you could download the latest version of the forms package from its CVS repository, or at least download a repository snapshot.
You can do that by going to this page of the Metastorage project. The forms package is in the same CVS repository as Metastorage. The Metastorage project snapshot archives also contain the forms package.
http://www.meta-language.net/download.html#cvs
Once you try it and have feedback to provide about the issues mentioned above, you can just post a comment to this article. Thank you in advance for your feedback.