Returns an XHTML compliant <input> tag with type="checkbox".
When creating multiple checkboxes with the same name, be sure to use an array for the
$name parameter (i.e. 'name[]'). The checkbox_tag is smart enough to create unique ID's
based on the $value parameter like so:
// one request variable with an array of checkbox values
echo checkbox_tag('choice[]', 1);
echo checkbox_tag('choice[]', 2);
echo checkbox_tag('choice[]', 3);
echo checkbox_tag('choice[]', 4);
// assuming you have Prototype.js enabled, you could do this
echo checkbox_tag('show_tos', 1, false, array('onclick' => "Element.toggle('tos'); return false;"));
Returns an HTML <form> tag that points to a valid action, route or URL as defined by <i>$url_for_options</i>.
By default, the form tag is generated in POST format, but can easily be configured along with any additional
HTML parameters via the optional $options parameter. If you are using file uploads, be sure to set the
multipart option to true.
Options: - multipart - When set to true, enctype is set to "multipart/form-data".
Returns a formatted ID based on the <i>$name</i> parameter and optionally the <i>$value</i> parameter.
This function determines the proper form field ID name based on the parameters. If a form field has an
array value as a name we need to convert them to proper and unique IDs like so:
name[] => name (if value == null)
name[] => name_value (if value != null)
name[bob] => name_bob
name[item][total] => name_item_total
Returns two XHTML compliant <input> tags to be used as a free-text date fields for a date range.
Built on the input_date_tag, the input_date_range_tag combines two input tags that allow the user
to specify a from and to date.
You can easily implement a JavaScript calendar by enabling the 'rich' option in the
$options parameter. This includes a button next to the field that when clicked,
will open an inline JavaScript calendar. When a date is selected, it will automatically
populate the tag with the proper date, formatted to the user's culture setting.
Note: The $name parameter will automatically converted to array names.
For example, a $name of "date" becomes date[from] and date[to]
Options: - rich - If set to true, includes an inline JavaScript calendar can auto-populate the date field with the chosen date
- before - string to be displayed before the input_date_range_tag
- middle - string to be displayed between the from and to tags
- after - string to be displayed after the input_date_range_tag
Returns an XHTML compliant <input> tag to be used as a free-text date field.
You can easily implement a JavaScript calendar by enabling the 'rich' option in the
$options parameter. This includes a button next to the field that when clicked,
will open an inline JavaScript calendar. When a date is selected, it will automatically
populate the tag with the proper date, formatted to the user's culture setting.
Symfony also conveniently offers the input_date_range_tag, that allows you to specify a to
and from date.
Options: - rich - If set to true, includes an inline JavaScript calendar can auto-populate the date field with the chosen date
Returns an XHTML compliant <input> tag with type="file".
Similar to the input_tag helper, the input_hidden_tag helper generates your basic XHTML tag and can utilize
any standard tag parameters passed in the optional $options parameter. The only difference is that it
creates the tag with type="file", meaning that next to the field will be a "browse" (or similar) button.
This gives the user the ability to choose a file from there computer to upload to the web server. Remember, if you
plan to upload files to your website, be sure to set the multipart option form_tag helper function to true
or your files will not be properly uploaded to the web server.
Returns an XHTML compliant <input> tag with type="hidden".
Similar to the input_tag helper, the input_hidden_tag helper generates an XHTML tag and can utilize
any standard tag parameters passed in the optional $options parameter. The only difference is
that it creates the tag with type="hidden", meaning that is not visible on the page.
Returns an XHTML compliant <input> tag with type="password".
Similar to the input_tag helper, the input_hidden_tag helper generates your basic XHTML tag and can utilize
any standard tag parameters passed in the optional $options parameter. The only difference is that it
creates the tag with type="password", meaning that the text entered into this field will not be visible to the end user.
In most cases it is replaced by * * * * * * * *. Even though this text is not readable, it is recommended that you do not
populate the optional $value option with a plain-text password or any other sensitive information, as this is a
potential security risk.
Returns a formatted set of <option> tags based on optional <i>$options</i> array variable.
The options_for_select helper is usually called in conjunction with the select_tag helper, as it is relatively
useless on its own. By passing an array of $options, the helper will automatically generate
Returns an XHTML compliant <input> tag with type="reset".
By default, this helper creates a submit tag with a name of reset. Also, the default
$value parameter (title of the button) is set to "Reset" which can be easily overwritten
by passing a $value parameter.
Returns a <select> tag populated with all the countries in the world.
The select_country_tag builds off the traditional select_tag function, and is conveniently populated with
all the countries in the world (sorted alphabetically). Each option in the list has a two-character country
code for its value and the country's name as its display title. The country data is retrieved via the sfCultureInfo
class, which stores a wide variety of i18n and i10n settings for various countries and cultures throughout the world.
Here's an example of an
Returns a <select> tag populated with all the languages in the world (or almost).
The select_language_tag builds off the traditional select_tag function, and is conveniently populated with
all the languages in the world (sorted alphabetically). Each option in the list has a two or three character
language/culture code for its value and the language's name as its display title. The country data is
retrieved via the sfCultureInfo class, which stores a wide variety of i18n and i10n settings for various
countries and cultures throughout the world. Here's an example of an
Returns an XHTML compliant <input> tag with type="image".
The submit_image_tag is very similar to the submit_tag, the only difference being that it uses an image
for the submit button instead of the browser-generated default button. The image is defined by the
$source parameter and must be a valid image, either local or remote (URL). By default, this
helper creates a submit tag with a name of commit to avoid conflicts with other parts of the
framework. It is recommended that you do not use the name "submit" for submit tags unless absolutely necessary.
Examples: // Assuming your image is in the /web/images/ directory
echo submit_image_tag('my_submit_button.gif');
Returns an XHTML compliant <input> tag with type="submit".
By default, this helper creates a submit tag with a name of commit to avoid
conflicts with other parts of the framework. It is recommended that you do not use the name
"submit" for submit tags unless absolutely necessary. Also, the default $value parameter
(title of the button) is set to "Save changes", which can be easily overwritten by passing a
$value parameter.