Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed changes for form elements #453

Open
bitcero opened this issue Nov 3, 2015 · 2 comments
Open

Proposed changes for form elements #453

bitcero opened this issue Nov 3, 2015 · 2 comments

Comments

@bitcero
Copy link

bitcero commented Nov 3, 2015

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.

@geekwright
Copy link
Contributor

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.

@mambax7
Copy link
Contributor

mambax7 commented Nov 4, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants