Latest Version: 0.9.6.2

form_tag

Form Tag Helpers


Functions

f check_box(name, value='1', checked=False, **options) ...

Creates a check box.

f end_form() ...

Outputs "</form>"

Example:

>>> end_form()
'</form>'

f file_field(name, value=None, **options) ...

Creates a file upload field.

If you are using file uploads then you will also need to set the multipart option for the form.

Example:

>>> file_field('myfile')
'<input id="myfile" name="myfile" type="file" />'

f form(url, method='POST', multipart=False, **options) ...

Starts a form tag that points the action to an url.

The url options should be given either as a string, or as a url() function. The method for the form defaults to POST.

Options:

multipart
If set to True, the enctype is set to "multipart/form-data".
method
The method to use when submitting the form, usually either "GET" or "POST". If "PUT", "DELETE", or another verb is used, a hidden input with name _method is added to simulate the verb over POST.

f hidden_field(name, value=None, **options) ...

Creates a hidden field.

Takes the same options as text_field

f password_field(name='password', value=None, **options) ...

Creates a password field

Takes the same options as text_field

f radio_button(name, value, checked=False, **options) ...

Creates a radio button.

The id of the radio button will be set to the name + value with a _ in between to ensure its uniqueness.

f select(name, option_tags='', **options) ...

Creates a dropdown selection box

option_tags is a string containing the option tags for the select box:

>>> select("people", "<option>George</option>")
'<select id="people" name="people"><option>George</option></select>'

Options:

  • multiple - If set to true the selection will allow multiple choices.

f start_form(url, method='POST', multipart=False, **options) ...

Starts a form tag that points the action to an url.

The url options should be given either as a string, or as a url() function. The method for the form defaults to POST.

Options:

multipart
If set to True, the enctype is set to "multipart/form-data".
method
The method to use when submitting the form, usually either "GET" or "POST". If "PUT", "DELETE", or another verb is used, a hidden input with name _method is added to simulate the verb over POST.

f submit(value='Save changes', name='commit', confirm=None, disable_with=None, **options) ...

Creates a submit button with the text value as the caption.

Options:

  • confirm - A confirm message displayed when the button is clicked.
  • disable_with - The value to be used to rename a disabled version of the submit button.

f text_area(name, content='', **options) ...

Creates a text input area.

Options:

  • size - A string specifying the dimensions of the textarea.

Example:

>>> text_area("body", '', size="25x10")
'<textarea cols="25" id="body" name="body" rows="10"></textarea>'

f text_field(name, value=None, **options) ...

Creates a standard text field.

value is a string, the content of the text field

Options:

  • disabled - If set to True, the user will not be able to use this input.
  • size - The number of visible characters that will fit in the input.
  • maxlength - The maximum number of characters that the browser will allow the user to enter.

Remaining keyword options will be standard HTML options for the tag.

See the source for more information.

Top