symfony API

sfWidget Class

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

1.3 API OpenSearch

Packages

You are currently browsing the symfony API for the 1.3 version. Switch to:

sfWidget is the base class for all widgets.

Inheritence

sfWidgetForm  <  sfWidget

Method Summary

  • sfWidget addOption($name, $value)
    Adds a new option value with a default value.
  • sfWidget addRequiredOption($name)
    Adds a required option.
  • string attributesToHtml($attributes)
    Converts an array of attributes to its HTML representation.
  • string attributesToHtmlCallback($k, $v)
    Prepares an attribute key and value for HTML representation.
  • configure($options, $attributes)
    Configures the current widget.
  • string escapeOnce($value)
    Escapes a string.
  • string fixDoubleEscape($escaped)
    Fixes double escaped strings.
  • string getAttribute($name)
    Returns the HTML attribute value for a given attribute name.
  • getAttributes()
    Returns the default HTML attributes.
  • string getCharset()
    Returns the charset to use when rendering widgets.
  • array getJavaScripts()
    Gets the JavaScript paths associated with the widget.
  • mixed getOption($name)
    Gets an option value.
  • array getOptions()
    Gets all options.
  • array getRequiredOptions()
    Returns all required option names.
  • array getStylesheets()
    Gets the stylesheet paths associated with the widget.
  • bool hasOption($name)
    Returns true if the option exists.
  • bool isXhtml()
    Returns whether to generate XHTML tags or not.
  • string render($name, $value, $attributes, $errors)
    Renders the widget as HTML.
  • renderContentTag($tag, $content, $attributes, )
    Renders a HTML content tag.
  • renderTag($tag, $attributes, )
    Renders a HTML tag.
  • sfWidget setAttribute($name, $value)
    Sets a default HTML attribute.
  • sfWidget setAttributes($attributes)
    Sets the HTML attributes.
  • setCharset($charset)
    Sets the charset to use when rendering widgets.
  • sfWidget setOption($name, $value)
    Changes an option value.
  • sfWidget setOptions($options)
    Sets the options.
  • setXhtml($boolean)
    Sets the XHTML generation flag.
  • __construct($options, $attributes)
    Constructor.

Method Details

  • (sfWidget) addOption ($name, $value) Browse code

    $name The option name
    $value The default value

    Adds a new option value with a default value.

    returns The current widget instance

  • (sfWidget) addRequiredOption ($name) Browse code

    $name The option name

    Adds a required option.

    returns The current widget instance

  • (string) attributesToHtml ($attributes) Browse code

    $attributes An array of attributes

    Converts an array of attributes to its HTML representation.

    returns The HTML representation of the HTML attribute array.

  • (string) attributesToHtmlCallback ($k, $v) Browse code

    $k The attribute key
    $v The attribute value

    Prepares an attribute key and value for HTML representation.


    It removes empty attributes, except for the value one.

    returns The HTML representation of the HTML key attribute pair.

  • configure ($options, $attributes) Browse code

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

    Configures the current widget.


    This method allows each widget to add options or HTML attributes
    during widget creation.

    If some options and HTML attributes are given in the sfWidget constructor
    they will take precedence over the options and HTML attributes you configure
    in this method.

  • (string) escapeOnce ($value) Browse code

    $value string to escape

    Escapes a string.

    returns escaped string

  • (string) fixDoubleEscape ($escaped) Browse code

    $escaped string to fix

    Fixes double escaped strings.

    returns single escaped string

  • (string) getAttribute ($name) Browse code

    $name The attribute name.

    Returns the HTML attribute value for a given attribute name.

    returns The attribute value, or null if the attribute does not exist

  • getAttributes () Browse code

    Returns the default HTML attributes.

  • (string) getCharset () Browse code

    Returns the charset to use when rendering widgets.

    returns The charset (defaults to UTF-8)

  • (array) getJavaScripts () Browse code

    Gets the JavaScript paths associated with the widget.

    returns An array of JavaScript paths

  • (mixed) getOption ($name) Browse code

    $name The option name

    Gets an option value.

    returns The option value

  • (array) getOptions () Browse code

    Gets all options.

    returns An array of named options

  • (array) getRequiredOptions () Browse code

    Returns all required option names.

    returns An array of required option names

  • (array) getStylesheets () Browse code

    Gets the stylesheet paths associated with the widget.


    The array keys are files and values are the media names (separated by a ,):

    array('/path/to/file.css' => 'all', '/another/file.css' => 'screen,print')

    returns An array of stylesheet paths

  • (bool) hasOption ($name) Browse code

    $name The option name

    Returns true if the option exists.

    returns true if the option exists, false otherwise

  • (bool) isXhtml () Browse code

    Returns whether to generate XHTML tags or not.

    returns true if widgets must be generated as XHTML, false otherwise

  • (string) render ($name, $value, $attributes, $errors) Browse code

    $name The name of the HTML widget
    $value The value of the widget
    $attributes An array of HTML attributes
    $errors An array of errors

    Renders the widget as HTML.


    All subclasses must implement this method.

    returns A HTML representation of the widget

  • renderContentTag ($tag, $content, $attributes, ) 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.

  • renderTag ($tag, $attributes, ) Browse code

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

    Renders a HTML tag.

  • (sfWidget) setAttribute ($name, $value) Browse code

    $name The attribute name
    $value The attribute value

    Sets a default HTML attribute.

    returns The current widget instance

  • (sfWidget) setAttributes ($attributes) Browse code

    $attributes An array of HTML attributes

    Sets the HTML attributes.

    returns The current widget instance

  • setCharset ($charset) Browse code

    $charset The charset

    Sets the charset to use when rendering widgets.

  • (sfWidget) setOption ($name, $value) Browse code

    $name The option name
    $value The value

    Changes an option value.

    returns The current widget instance

    throws InvalidArgumentException when a option is not supported

  • (sfWidget) setOptions ($options) Browse code

    $options An array of options

    Sets the options.

    returns The current widget instance

  • setXhtml ($boolean) Browse code

    $boolean true if widgets must be generated as XHTML, false otherwise

    Sets the XHTML generation flag.

  • __construct ($options, $attributes) Browse code

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

    Constructor.

    throws InvalidArgumentException when a option is not supported