formr

Create and Validate PHP Forms in Seconds.

GPL-2.0 License

Downloads
18.2K
Stars
360
Committers
10

Bot releases are hidden (Show)

formr - 1.3.2

Published by timgavin over 3 years ago

Bug fixes

formr - 1.3.1

Published by timgavin over 3 years ago

Bug fixes

formr - 1.3

Published by timgavin over 3 years ago

Formr 1.3

Big Validation Update!

Validation had a major overhaul, with some new rules, fixes to others, and many other goodies.

Validation Rule Change 🚨

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.

New Validation Rules

Regex

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_]+/]');
}

Greater Than or Equal to

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]');
}

Less Than or Equal to

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]');
}

Before

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');
}

After

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');
}

New Validation Aliases

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

New Method

Added a dump() method which formats a print_r() of your data or string.

Updated Method

Modified the dd() (die dump) method to now kill the script after printing the data.

Added a Honeypot

You can now use $form->honeypot = 'my_form_field' to kill the script if a bot submits the form.

Fixed

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.

formr - 1.2.6

Published by timgavin over 3 years ago

Bug fixes

formr - 1.2.5

Published by timgavin over 3 years ago

  • Fixes a bug when adding hidden elements to $form->open()
  • Adds an option to disable automatic echoing of elements and messages
formr - 1.2.4

Published by timgavin almost 4 years ago

Fixed issues with CSRF and composer.json

formr - 1.2.3

Published by timgavin almost 4 years ago

Nothing fancy, just bug fixes.

formr - 1.2.2

Published by timgavin almost 4 years ago

What's New in Formr 1.2.2

Added support for Bulma

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');

Added Heading to Message Properties

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 ok() method

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!';
    }
}

Added a Property to Display Field Validation

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;

Wrappers now Utilize Traits

Did quite a bit of work cleaning up the wrappers and moved Bootstrap and Bulma to their own traits for easier extendability.

Updated Validation Rules

Updated the alpha and alpha_numeric validation rules to allow for spaces.

formr - 1.2.1

Published by timgavin almost 4 years ago

What's New in Formr 1.2.1

Along with some bug fixes and minor enhancements, we have...

New Documentation

The Formr documentation has been completely rewritten and brought up to date, and is available at https://formr.github.io

New Method Aliases

$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()

Say Goodbye to Echo

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();

New Messaging Properties

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!';
}
formr - 1.2

Published by timgavin about 4 years ago

What's New in Formr 1.2

Warning: this update includes breaking changes from earlier versions.

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!

Upgrading From 1.1

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();

Plugin Overhaul

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.

Namespaces

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 in $_SESSION

Checkbox arrays are now properly handled when using a $_SESSION.

New Field Aliases

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()

New Submit Button

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>

Rename File Uploads With a String

You can now rename an uploaded file with a custom string (thank you to A.F. for the suggestion).

$form->upload_rename = 'string[myFilename]';

The datetime() Method was Updated

The input <input type="datetime"> is obsolete. Therefore $form->datetime() will now return <input type="datetime-local">

The Internal $_SESSION was Renamed

If 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.

Empty the $_SESSION

You can now empty all Formr $_SESSION arrays with unset_session() method.

$form->session = 'myForm';
$form->session_values = true;
$form->unset_session();

Internal Messages

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...

formr - 1.1.8

Published by timgavin about 4 years ago

Fixes an issue that would result if a string wasn't present

formr - 1.1.7

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

formr - 1.1.6

Published by timgavin over 4 years ago

Can now pass an array to your functions in the MyDropdowns class
Misc. improvements

formr - 1.1.5

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.

formr - 1.1.4

Published by timgavin over 4 years ago

Fixed an issue with hidden fields not showing properly while using fastform()

formr - 1.1.3

Published by timgavin over 4 years ago

Removed version from composer.json to enable automatic versioning for packagist.

formr - 1.1.2

Published by timgavin over 4 years ago

Fixed an issue with unsupported images being uploaded

formr - 1.1.1

Published by timgavin over 4 years ago

A few minor tweaks and updates

formr - 1.1

Published by timgavin over 4 years ago

Added ability to install via Composer, plus numerous updates and fixes

formr - 1.0.0

Published by timgavin over 9 years ago

Initial release. Smashes champagne bottle against octocat