symfony API

sfWidgetForm Class

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

Packages

You are currently browsing the symfony API for the 1.4 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)
    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.
  • sfWidgetFormSchema|null getParent()
    Returns the parent widget schema.
  • Boolean isHidden()
    Returns true if the widget is hidden.
  • bool needsMultipartForm()
    Returns true if the widget needs a multipart form.
  • string renderContentTag($tag, $content, $attributes)
    Renders a HTML content tag.
  • string renderTag($tag, $attributes)
    Renders a HTML tag.
  • sfWidget setDefault($value)
    Sets the default value for the widget.
  • sfWidget setHidden($boolean)
    Sets the hidden flag for the widget.
  • sfWidget setIdFormat($format)
    Sets the format for HTML id attributes.
  • sfWidget setLabel($value)
    Sets the label for the widget.
  • sfWidgetForm setParent($widgetSchema)
    Sets the parent widget schema.
  • string translate($text, $parameters)
    Translates the given text.
  • array translateAll($texts, $parameters)
    Translates all values of the given array.
  • __construct($options, $attributes)
    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)

    $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)

    $name The field name
    $value The field value

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


    This method 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

    This method also changes all invalid characters to an underscore (_):

    Ids must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits
    ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

    returns The field id or null.

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

    Generates a two chars range

  • (string) getDefault ()

    Returns the default value for the widget.

    returns The default value

  • (string) getIdFormat ()

    Gets the HTML format string for id attributes.

    returns The format string

  • (string) getLabel ()

    Returns the label for the widget.

    returns The label

  • (sfWidgetFormSchema|null) getParent ()

    Returns the parent widget schema.


    If no schema has been set with setWidgetSchema(), NULL is returned.

  • (Boolean) isHidden ()

    Returns true if the widget is hidden.

    returns true if the widget is hidden, false otherwise

  • (bool) needsMultipartForm ()

    Returns true if the widget needs a multipart form.

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

  • (string) renderContentTag ($tag, $content, $attributes)

    $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)

    $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

  • (sfWidget) setDefault ($value)

    $value The default value

    Sets the default value for the widget.

    returns The current widget instance

  • (sfWidget) setHidden ($boolean)

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

    Sets the hidden flag for the widget.

    returns The current widget instance

  • (sfWidget) setIdFormat ($format)

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

    Sets the format for HTML id attributes.

    returns The current widget instance

  • (sfWidget) setLabel ($value)

    $value The label

    Sets the label for the widget.

    returns The current widget instance

  • (sfWidgetForm) setParent ($widgetSchema)

    Sets the parent widget schema.

    returns The current widget instance

  • (string) translate ($text, $parameters)

    $text The text with optional placeholders
    $parameters The values to replace the placeholders

    Translates the given text.

    returns The translated text

  • (array) translateAll ($texts, $parameters)

    $texts The texts with optional placeholders
    $parameters The values to replace the placeholders

    Translates all values of the given array.

    returns The translated texts

  • __construct ($options, $attributes)

    $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