Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (39 sloc) 2.67 KB
<!--- @@Copyright: Copyright (c) 2011 ImageAid. All rights reserved. --->
<!--- @@License: Free :) --->
<cfsetting enablecfoutputonly="true">
<h1>StatesAndCountries for Wheels v1.0.1</h1>
<p>A very basic plugin to access queries for US states, Canadian provinces, and Countries. I created this because I cannot recall an application that I've built over the years that did not need a State or Country drop-down in some form somewhere in the application.</p>
<p>The plugin comes with three asset files: us_states.xml, canadian_provinces.xml, and countries.xml. When one of the four methods (below) are called for the first time, the relevant XML file is read and a query is created, stored in the application scope and returned. Subsequent calls to the same method will pull the query from the application scope rather than recreating it time and again.</p>
This plugin provides four methods for use in your controllers: <tt>getUSStates()</tt>, <tt>getCanadianProvinces()</tt>, <tt>getUSStatesAndCanadianProvinces()</tt> <tt>getCountries()</tt>. All methods do not accept parameters and all return a query. Each row in the returned query has two columns: <tt>name</tt> and <tt>abbreviation</tt>.
<p>Once installed, the plugin is quite easy to use. In the desired controller(s), call the plugin method you want to access.</p>
// this is an excerpt from a controller called Users
function new(){
usStates = getUSStates();
countries = getCountries();
user = model("User").new();
In the relevant view, you could loop over the queries and output the data or use the queries in a select() call along the lines of the following:
&lt;div class="form_field"&gt;
#select(objectName='user', property='state', label='State', options=usStates, valueField="abbreviation", textField="name")#
&lt;div class="form_field"&gt;
#select(objectName='user', property='state', label='State', options=countries, valueField="abbreviation", textField="name")#
<p>SimpleFlickr was created by <a href="">Craig Kaminsky</a> of <a href="">ImageAid, Incorporated</a>.
<cfsetting enablecfoutputonly="false">