CodeIgniter Forums
CI4 Form Builder Lib - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: CI4 Form Builder Lib (/showthread.php?tid=87945)



CI4 Form Builder Lib - rafaelwendel - 06-24-2023

Hi there,

I developed a lib called "Ci4FormBuilder", which helps to create forms (and their components) in an object-oriented way. The repository and documentation can be accessed at the following link.

https://github.com/rafaelwendel/CI4FormBuilder

Suggestions are welcome!


RE: CI4 Form Builder Lib - datamweb - 06-24-2023

Good news, thanks for sharing.


RE: CI4 Form Builder Lib - iRedds - 06-24-2023

I think this approach complicates the work with forms. In fact, this is a wrapper over helpers.
Does this solution have any advantage?


RE: CI4 Form Builder Lib - rafaelwendel - 06-24-2023

(06-24-2023, 05:45 PM)iRedds Wrote: I think this approach complicates the work with forms. In fact, this is a wrapper over helpers.
Does this solution have any advantage?

Hello IRedds,

I developed this lib for a personal project, and it helped me in aspects like:

- Define (or edit) the forms template and its components in an easier way, like before and after <form> tag (to add for example an alert with success/error message of a submit), before and after each field, styles of message validation errors, ...
- Easy to set the field structure (with its label, and inside a "<div>"). If necessary, I change the template and all fields will be changed (or each field can be its own template)
- Set the field values just by passing
PHP Code:
$this->request->getPost() 
or a model response (Like
PHP Code:
$userModel->find(1
)
- Just set
PHP Code:
$validation->getErrors() 
to display the validation error message in their respective fields.


Anyway. I hope it can be an a good alternative!

Thanks!


RE: CI4 Form Builder Lib - kenjis - 06-24-2023

Thank you for sharing!

This is an OOP way to build forms.
It would help coding when we don't like to write HTML forms in Views.


RE: CI4 Form Builder Lib - iRedds - 06-24-2023

But the same can be done in a simple template with helpers.