Create and Validate PHP Forms in Seconds.
GPL-2.0 License
Bot releases are hidden (Show)
Published by timgavin over 3 years ago
Bug fixes
Published by timgavin over 3 years ago
Bug fixes
Published by timgavin over 3 years ago
Validation had a major overhaul, with some new rules, fixes to others, and many other goodies.
Potential breaking change! The allow_html
validation rule now overrides and nullifies all other string modifier rules.
Boolean rules such as min
, max
, etc. still work with allow_html
, but basically: if you use allow_html
no other string manipulations will occur. Which makes sense really, because if you're going to allow HTML you're going to allow anything.
Added new regex and not_regex validation rules, to allow for regex matching.
if($form->submitted()) {
$username = $form->post('username', 'Username|Only letters, numbers, and underscores', 'regex[/[^a-zA-Z_]+/]');
}
Added a greater_than_or_equal
rule, with an alias of gte
for matching numbers.
if($form->submitted()) {
$age = $form->post('age', 'Age', 'gte[18]');
}
Added a less_than_or_equal
rule, with an alias of lte
for matching numbers.
if($form->submitted()) {
$weight = $form->post('weight', 'Weight', 'lte[45]');
}
Added a before
rule, which checks if the supplied date is before the current date (using the server's time).
if($form->submitted()) {
$date = $form->post('date', 'Date', 'before');
}
Added an after
rule, which checks if the supplied date is after the current date (using the server's time).
if($form->submitted()) {
$date = $form->post('date', 'Date', 'after');
}
alpha_dash
now has an alias of ad
alpha_numeric
now has an alias of an
exact_length
now has an alias of el
greater_than
now has an alias of gt
less_than
now has an alias of lt
max_length
now has an alias of ml
valid_email
now has an alias of email
valid_ip
now has an alias of ip
valid_url
now has an alias of url
Added a dump()
method which formats a print_r()
of your data or string.
Modified the dd()
(die dump) method to now kill the script after printing the data.
You can now use $form->honeypot = 'my_form_field'
to kill the script if a bot submits the form.
Fixed a salting bug when hashing passwords.
Fixed a validation bug where multiple rules were not being applied properly.
Fixed an issue when sending email where the email
field would be validated even if the field was empty.
Fixed an issue where custom validation messages would not display.
Fixed an issue where the custom validation messages would not cascade properly.
Fixed an issue where min
validation would pass if the submitted value was the same length as the min value.
Fixed a typo in the valid_url
validation method.
Fixed an issue where fastpost('POST')
would return an illegal string offset error.
Fixed an issue where an array of hidden elements would not generate properly.
Fixed an issue where label_close()
wouldn't print.
Numerous additional fixes and improvements.
Published by timgavin over 3 years ago
Bug fixes
Published by timgavin over 3 years ago
$form->open()
Published by timgavin almost 4 years ago
Fixed issues with CSRF and composer.json
Published by timgavin almost 4 years ago
Nothing fancy, just bug fixes.
Published by timgavin almost 4 years ago
Formr now supports the fantastic Bulma framework! Just add bulma
as the wrapper when instantiating a from and Formr will take care of the rest.
$form = new Formr\Formr('bulma');
You can now add headings to your message properties. Just type your message, then a pipe character and the heading text.
$form->success_message = 'We have received your submission|Thank You!';
Added a new ok()
method to easily check if there are any errors after the form has been submitted.
if($form->submitted()) {
if($form->ok()) {
$form->success_message = 'We have received your submission|Thank You!';
}
}
A new show_valid
property helps you distinguish the successfully filled form fields from the ones with errors after the form has been submitted. Works with Bootstrap and Bulma.
$form->show_valid = true;
Did quite a bit of work cleaning up the wrappers and moved Bootstrap and Bulma to their own traits for easier extendability.
Updated the alpha
and alpha_numeric
validation rules to allow for spaces.
Published by timgavin almost 4 years ago
Along with some bug fixes and minor enhancements, we have...
The Formr documentation has been completely rewritten and brought up to date, and is available at https://formr.github.io
$form->open()
Is an alias of $form->form_open()
$form->close();
Is an alias of $form->form_close()
$form->info();
Is an alias of $form->form_info()
It's no longer required to issue the echo
statement when building forms.
Previously you had to do this.
echo $form->form_open();
echo $form->input_text('name','Name');
echo $form->input_submit();
echo $form->form_close();
Now you can do this.
$form->open();
$form->text('name','Name');
$form->submit_button();
$form->close();
Now you can pass success
, warning
, and info
messages directly through the messages
method.
$success_message = 'This is a success message';
$warning_message = 'This is a warning message';
$info_message = 'This is an info messsage';
if (!$form->errors()) {
$form->success_message = 'Form Submitted!';
}
Published by timgavin about 4 years ago
This is the biggest update since Formr was released! Among the usual fixes and tweaks, the plugin system has been overhauled, there are new form fields, a new button, and much more!
Formr now has a namespace, so all you really need to do is add the new namespace when initializing Formr. Everything should contine to work after that. With that said: Test, Test, Test!
$form = new Formr\Formr();
One of the biggest changes is the removal of the my_classes
directory from the core, as it never should have been there in the first place. If you had custom classes, and updated Formr via composer, you'd overwite your classes. Not good.
The plugin classes have been moved into their own repo. To put them back into Formr, it's as simple as downloading the repo and moving the my_classes
folder into the Formr folder.
As mentioned, I've added a Formr
namespace, so now when you init Formr you must include the namespace.
$form = new Formr\Formr();
Checkbox arrays are now properly handled when using a $_SESSION
.
All form field methods have received an alias in hopes this will speed up your development, even if just a little bit. This means you now have the option to use $form->text()
instead of $form->input_text()
, and so on.
$form->button()
$form->checkbox()
$form->checkbox_inline()
$form->color()
$form->date()
$form->datetime()
$form->datetime_local()
$form->dropdown()
$form->dropdown_multiple()
$form->email()
$form->file()
$form->file_multiple()
$form->hidden()
$form->month()
$form->number()
$form->password()
$form->radio()
$form->radio_inline()
$form->range()
$form->search()
$form->select()
$form->select_multiple()
$form->tel()
$form->text()
$form->textarea()
$form->time()
$form->upload()
$form->upload_multiple()
$form->url()
$form->week()
Added a new $form->submit_button()
function, which accepts one (optional) parameter for the button label. As always, if you're using Bootstrap it will add the appropriate button classes for you.
echo $form->submit_button();
// produces
<button type="submit" name="submit" id="submit">
Submit
</button>
echo $form->submit_button('FooBar');
// produces
<button type="submit" name="submit" id="submit">
FooBar
</button>
You can now rename an uploaded file with a custom string (thank you to A.F. for the suggestion).
$form->upload_rename = 'string[myFilename]';
datetime()
Method was UpdatedThe input <input type="datetime">
is obsolete. Therefore $form->datetime()
will now return <input type="datetime-local">
$_SESSION
was RenamedIf you were using CSRF or flash mesaging, the internal $_SESSION
would have been named $_SESSION['token']
, or $_SESSION['flash']
, etc., which could potentially cause some issues if you were implementing Formr in a system which already used a session with that name.
Sessions have now been renamed to $_SESSION['formr']['token']
, etc.. This shouldn't cause any issues, but it's still a good idea to test before putting this update into production.
$form->session
has remained untouched, so you don't have to worry about renaming your custom session name.
$_SESSION
You can now empty all Formr $_SESSION
arrays with unset_session()
method.
$form->session = 'myForm';
$form->session_values = true;
$form->unset_session();
Began working on better error messages when something goes wrong, so instead of seeing a generic PHP error, you will now see messages on how to fix the problem. Ongoing...
Published by timgavin about 4 years ago
Fixes an issue that would result if a string wasn't present
Published by timgavin about 4 years ago
• You can now add a custom string when adding a field to the add_to_errors()
method
• Added CSRF to fastforms
• The CSRF field will now re-generate after a form has been submitted
• HTML will now properly populate in fields after the form has been submitted
• Fixed an issue where CSS classes would not be inserted into an element if there was text in the 5th parameter
Published by timgavin over 4 years ago
Can now pass an array to your functions in the MyDropdowns class
Misc. improvements
Published by timgavin over 4 years ago
Fixed an issue with the wrapper and added a new input()
method, which allows you to create inputs directly from arrays.
Published by timgavin over 4 years ago
Fixed an issue with hidden fields not showing properly while using fastform()
Published by timgavin over 4 years ago
Removed version from composer.json to enable automatic versioning for packagist.
Published by timgavin over 4 years ago
Fixed an issue with unsupported images being uploaded
Published by timgavin over 4 years ago
A few minor tweaks and updates
Published by timgavin over 4 years ago
Added ability to install via Composer, plus numerous updates and fixes
Published by timgavin over 9 years ago
Initial release. Smashes champagne bottle against octocat