symfony API

sfWidgetForm Class

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

1.2 API OpenSearch

Packages

You are currently browsing the symfony API for the 1.2 version. Switch to:
This version of symfony is not maintained anymore.
If some of your projects still use this version, consider upgrading as soon as possible.

sfWidgetForm is the base class for all form widgets.

Method Summary

  • array fixFormId($attributes)
    Adds an HTML id attributes to the array of attributes if none is given and a name attribute exists.
  • string generateId($name, $value = null)
    Returns a formatted id based on the field name and optionally on the field value.
  • array generateTwoCharsRange($start, $stop)
    Generates a two chars range
  • string getDefault()
    Returns the default value for the widget.
  • string getIdFormat()
    Gets the HTML format string for id attributes.
  • string getLabel()
    Returns the label for the widget.
  • Boolean isHidden()
    Returns true if the widget is hidden.
  • bool needsMultipartForm()
    Returns true if the widget needs a multipart form.
  • string renderContentTag($tag, $content = null, $attributes = array())
    Renders a HTML content tag.
  • string renderTag($tag, $attributes = array())
    Renders a HTML tag.
  • setDefault($value)
    Sets the default value for the widget.
  • setHidden($boolean)
    Sets the hidden flag for the widget.
  • setIdFormat($format)
    Sets the format for HTML id attributes.
  • setLabel($value)
    Sets the label for the widget.
  • __construct($options = array(), $attributes = array())
    Constructor.

Methods inherited from sfWidget

addOption , addRequiredOption , attributesToHtml , attributesToHtmlCallback , configure , escapeOnce , fixDoubleEscape , getAttribute , getAttributes , getCharset , getJavaScripts , getOption , getOptions , getRequiredOptions , getStylesheets , hasOption , isXhtml , render , renderContentTag , renderTag , setAttribute , setAttributes , setCharset , setOption , setOptions , setXhtml , __construct

Method Details

  • (array) fixFormId ($attributes) Browse code

    $attributes An array of attributes

    Adds an HTML id attributes to the array of attributes if none is given and a name attribute exists.

    returns An array of attributes with an id.

  • (string) generateId ($name, $value = null) Browse code

    $name The field name
    $value The field value

    Returns a formatted id based on the field name and optionally on the field value.


    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 The field id or null.

  • (array) generateTwoCharsRange ($start, $stop) Browse code

    $start
    $stop

    Generates a two chars range

  • (string) getDefault () Browse code

    Returns the default value for the widget.

    returns The default value

  • (string) getIdFormat () Browse code

    Gets the HTML format string for id attributes.

    returns The format string

  • (string) getLabel () Browse code

    Returns the label for the widget.

    returns The label

  • (Boolean) isHidden () Browse code

    Returns true if the widget is hidden.

    returns true if the widget is hidden, false otherwise

  • (bool) needsMultipartForm () Browse code

    Returns true if the widget needs a multipart form.

    returns true if the widget needs a multipart form, false otherwise

  • (string) renderContentTag ($tag, $content = null, $attributes = array()) Browse code

    $tag The tag name
    $content The content of the tag
    $attributes An array of HTML attributes to be merged with the default HTML attributes

    Renders a HTML content tag.


    The id attribute is added automatically to the array of attributes if none is specified. If uses for "id_format" option to generate the id.

    returns An HTML tag string

  • (string) renderTag ($tag, $attributes = array()) Browse code

    $tag The tag name
    $attributes An array of HTML attributes to be merged with the default HTML attributes

    Renders a HTML tag.


    The id attribute is added automatically to the array of attributes if none is specified. If uses for "id_format" option to generate the id.

    returns An HTML tag string

  • setDefault ($value) Browse code

    $value The default value

    Sets the default value for the widget.

  • setHidden ($boolean) Browse code

    $boolean true if the widget must be hidden, false otherwise

    Sets the hidden flag for the widget.

  • setIdFormat ($format) Browse code

    $format The format string (must contain a %s for the id placeholder)

    Sets the format for HTML id attributes.

  • setLabel ($value) Browse code

    $value The label

    Sets the label for the widget.

  • __construct ($options = array(), $attributes = array()) Browse code

    $options An array of options
    $attributes An array of default HTML attributes

    Constructor.


    Available options:

    * id_format: The format for the generated HTML id attributes (%s by default)
    * is_hidden: true if the form widget must be hidden, false otherwise (false by default)
    * needs_multipart: true if the form widget needs a multipart form, false otherwise (false by default)
    * default: The default value to use when rendering the widget
    * label: The label to use when the widget is rendered by a widget schema