Download the PHP package truecastdesign/welder without Composer
On this page you can find all versions of the php package truecastdesign/welder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package welder
Welder - HTML5 Form Builder for PHP
This library provides a simple powerful HTML5 form builder, validator, spam checker, spam submitter, form contents emailer, and more.
It is designed with the end user in mind so the typing is minimized as much as possible and the syntax is as much like HTML as possible with added functionality.
This library blocks form submissions from domains other than the domain the site is on. It also protects against Cross Site Request Forgeries by default.
Install
To install with composer:
Requires PHP 7.0 or newer.
Usage
How to build a form:
Make a new instance
Output the form tag and other hidden fields
The above code will output this HTML
File Uploads
If you are going to use File Uploads in the form, than you need to have the enctype set to multipart/form-data. To set that, pass file=true as an argument on the start method.
Text Fields
The method names are the type of field you want. textarea, checkbox, etc. The double quotes in the property string are not needed if the value does not have spaces. Saves typing by skipping them if not needed.
Supported field types: text, password, hidden, submit, reset, image, file, number, email, tel, date, datetime, datetime-local, month, search, time, url, week, color, range, checkbox, radio, select, button.
The above code will output this HTML
Other examples:
Checkboxes
The above code will output this HTML
Select Menus
The above code will output this HTML
Use an array to set create the options.
Custom Errors
Use the 'error' key to set a custom error to display when the form is submitted and validation errors are displayed.
Form Validation
The validate method takes the field name on the left and the validation method to the right of the equal sign. The available validation methods start with validate_ in the class so you can look them up to see what they do. The clean method runs several content cleaning functions to sanitize the data if it does not conform to any set pattern like emails or names, etc.
You can use the spam method to check if the form is spam. If you want to use Akismet, just pass it the field names for their name, email, and content. They need to be in that order.
If you want to make sure the form does not contain any urls then add the nourls flag like: nourls=true. Setting it to true checks all the fields. If you want to only check certain fields do that like this: nourls="field1,field2".
If you want to check the captcha add the captcha flag. Display the captcha on the page with <?$F->captcha()?>. You will need to move the form-captcha.php file to a public accessible directory and change the include path into to access the Welder.php file.
Spam Content Checking
Welder uses several spam checking method to determine if an email message is likely to be spam. Use the keyword spamcontent and set it equal to the field names you want to check. Example: spamcontent="subject,message"
Gibberish: matches text that is not real words but just random repeated keystrokes like "asdasd" or "qwejjjjjeeee"
Too Many Consonants: Checks if the message has words will more than 6 consonants in a row. Usually means it is invalid words and spam
Keyword Search: Search message for spam keyword phrases that spammers commonly use to sell you something.
Getting and Setting Field values
If you want to populate the form fields from a database record or other source on display of form but not submitting it, use the setFieldValues method to pass a key value array of field name to value. You can set more than one at a time.
You can do this as an else statement on the if($F->validate()) method call if you make sure the view has access to the same Welder instance. Pass the $F variable to the view if needed.
To get a field value or all field values in the view use:
Get all in array.
Configuration
Turn off CSRF protection
Turn off inline field errors
Normally there is outputted a span like:
before each field. If you don't want this tag outputted for some reason, turn it off using the below code.
Use more than one form in a view or controller
You need to set the custom action field value on both the controller instance and the view instance so they match.