Proposed changes for form elements
Currently we have several form fields types that can be used in Xoops forms, but I think that the implementation could be better.
One change that could be very useful an productive for developers and designers is to add support for construct elements passing an array with all parameters.
Consider the current way:
new Xoops\Form\Text('Caption', 'Name', 'size', ...));
In addition, we could use:
new Xoops\Form\Text(array(
'caption' => 'Field caption',
'name' => 'Field name',
'id' => 'Field ID',
'value' => 'Field value',
'data-something' => 'Some data for scripts like jQuery or Angular',
...
));
I think that this new way have several advantages over current one, specially when consider the creation of modules with more interactive and dynamic features, specially those that use intensively AJAX. Also this way allow a more flexible use of fields trough PHP, and allows to integrate perfectly with javascript. This can be very useful to create new fields (for example a extension that provide new field types) or apps.
Another advantage of this change is that we can maintain the backward compatibility. Existing modules still can use the current way, while new ones can implement the new form.
I like this idea!
Most of the attributes moved to an internal array already. There are a few exceptions, such as caption, value, and a few others, but it would be easy to consolidate everything for the definition phase.
I like the idea that an entire element could be defined in one call. This greatly simplifies defining a form.
Let me take a deeper look, but I think this would be quick and easy, and a great addition.
:+1: