TQ
dev.com

Blog about software development

Subscribe

MintyPHP Forms: a flexible PHP form builder

18 May 2025 - by 'Maurits van der Schee'

Forms play an important role in business software. Business software typically loads data from a relational database into a form, allows users to change the data and then saves the data from the form back into the database. If you make a lot of business software you have to create and design a lot of forms. To allow you to create nice looking forms (using Bulma for instance) without having to type a lot of boilerplate code I created MintyPHP Forms.

It allows you to write things like:

$form = E::form([
  E::field(E::text('user'),E::label('Username'),[V::required('Username is required')]),
  E::field(E::password('pass'),E::label('Password')),
  E::field(E::submit('Login')),
]);

That renders as:

example.png

You can fill the form using:

$form->fill($_POST);

And you can validate the data using:

$form->validate(); // returns true or false

When the form validates you can extract it's data:

$data = $form->extract(); // $data = ['user'=>'...','pass'=>'...']

You can render a filled and optionally validated form using:

$form->render(); // outputs the form with data and errors

I've implemented this without any dependencies and I've written already 44 tests to ensure that the code is stable and working. I'm currently adding some more tests and adding some documentation. Any feedback is more than welcome.

See: https://github.com/mintyphp/forms

Enjoy!


PS: Liked this article? Please share it on Facebook, Twitter or LinkedIn.