Skip to content

CFWheels plugin for adding a marked-up asterisk next to required fields.

License

Notifications You must be signed in to change notification settings

liquifusion/cfwheels-required-fields

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CFWheels Required Fields Plugin

Use this plugin to append a marked up asterisk to the labels of required fields.

By default the added markup looks like this:

<span class="required">*</span>

Usage/Examples

The plugin will look at validations set on the object form helpers' properties to determine whether or not a validatesPresenceOf validation is set (manually or automatically).

You can override this by behavior when calling the form helper as well. Just set the required argument to true or false in the call to the form helper:

<cfoutput>
<!--- Force `name` field to required --->
#textField(objectName="category", property="name", required=true)#

<!--- Force `slug` field to appear as optional --->
#textField(objectName="category", property="slug", required=false)#
</cfoutput>

You can also use this plugin with the form tag functions by manually adding the required argument.

<cfoutput>
<!--- The "Tag" form helpers always need the `required` argument --->
#textFieldTag(name="Search", value=params.search, required=true)#
</cfoutput>

Configuration

You can modify some minor details of the required field indicator that appears. (By default, it is an asterisk.)

Just set the following variables in config/settings.cfm to override.

Setting Type Default Description
application.requiredFields.containerElement string span Container element around required field indicator.
application.requiredFields.containerClass string required Class set on container element around required field indicator.
application.requiredFields.indicatorText string * Required field indicator.

Credits

This plugin was created by Chris Peters with support from Liquifusion Studios. Thanks to James Gibson for technical advice and Troy Murray for assistance with CFWheels compatibility testing.

To submit an issue or fork this plugin, visit the liquifusion/cfwheels-required-fields repository on GitHub.

License

The MIT License (MIT)

Copyright (c) 2011-2016 Liquifusion Studios

About

CFWheels plugin for adding a marked-up asterisk next to required fields.

Resources

License

Stars

Watchers

Forks

Packages

No packages published