symfony API

sfWidgetFormSchema 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.

sfWidgetFormSchema represents an array of fields.

Inheritence

sfWidgetFormSchemaDecorator, sfWidgetFormSchemaForEach  <  sfWidgetFormSchema  <  sfWidgetForm < sfWidget

Method Summary

  • addFormFormatter($name, $formatter)
    Adds a form formatter.
  • string generateName($name)
    Generates a name.
  • string getDefault($name = null)
    Gets the default value of a field.
  • array getDefaults()
    Returns the defaults values for the widget schema.
  • getFields()
    Returns an array of fields.
  • getFormFormatter()
    Returns the form formatter to use for widget schema rendering
  • string getFormFormatterName()
    Gets the form formatter name that will be used to render the widget schema.
  • array getFormFormatters()
    Returns all the form formats defined for this form schema.
  • string getGlobalErrors($errors)
    Gets errors that need to be included in global errors.
  • string getHelp($name)
    Gets a text help by field name.
  • array getHelps()
    Sets the help texts.
  • array getJavaScripts()
    Gets the JavaScript paths associated with the widget.
  • string getLabel($name = null)
    Gets a label by field name.
  • array getLabels()
    Gets the labels.
  • string getNameFormat()
    Gets the format string for the name HTML attribute.
  • getParent()
    Gets the parent widget schema.
  • array getPositions()
    Gets the positions of the fields.
  • array getStylesheets()
    Gets the stylesheet paths associated with the widget.
  • moveField($field, (constant) $action, $pivot = null)
    Moves a field in a given position
  • bool needsMultipartForm()
    Returns true if the widget schema needs a multipart form.
  • bool offsetExists($name)
    Returns true if the schema has a field with the given name (implements the ArrayAccess interface).
  • offsetGet($name)
    Gets the field associated with the given name (implements the ArrayAccess interface).
  • offsetSet($name, (sfWidget) $widget)
    Sets a field (implements the ArrayAccess interface).
  • offsetUnset($name)
    Removes a field by name (implements the ArrayAccess interface).
  • string render($name, $values = array(), $attributes = array(), $errors = array())
    Renders the widget.
  • string renderField($name, $value = null, $attributes = array(), $errors = array())
    Renders a field by name.
  • setDefault($name, $value = null)
    Sets the default value for a field.
  • setDefaultFormFormatterName($name)
    Sets the generic default formatter name used by the class. If you want all of your forms to be generated with the format, you can do it in a project or application configuration class:
  • setDefaults($values)
    Sets the default values for the widget.
  • setFormFormatterName($name)
    Sets the form formatter name to use when rendering the widget schema.
  • setHelp($name, $help)
    Sets a help text.
  • setHelps($helps)
    Sets the help texts to render for each field.
  • setLabel($name, $value = null)
    Sets a label.
  • setLabels($labels)
    Sets the label names to render for each field.
  • setNameFormat($format)
    Sets the format string for the name HTML attribute.
  • setParent($parent = null)
    Sets the parent widget schema.
  • setPositions($positions)
    Sets the positions of the fields.
  • __clone()
  • __construct($fields = null, $options = array(), $attributes = array(), $labels = array(), $helps = array())
    Constructor.

Methods inherited from sfWidgetForm

fixFormId , generateId , generateTwoCharsRange , getDefault , getIdFormat , getLabel , isHidden , needsMultipartForm , renderContentTag , renderTag , setDefault , setHidden , setIdFormat , setLabel , __construct

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

  • addFormFormatter ($name, $formatter) Browse code

    $name The formatter name
    $formatter An sfWidgetFormSchemaFormatter instance

    Adds a form formatter.

  • (string) generateName ($name) Browse code

    $name The name

    Generates a name.

    returns The generated name

  • (string) getDefault ($name = null) Browse code

    $name The field name (required - the default value is here because PHP do not allow signature changes with inheritance)

    Gets the default value of a field.

    returns The default value

  • (array) getDefaults () Browse code

    Returns the defaults values for the widget schema.

    returns An array of default values

  • getFields () Browse code

    Returns an array of fields.

    returns An array of sfWidget instance

  • getFormFormatter () Browse code

    Returns the form formatter to use for widget schema rendering

    returns sfWidgetFormSchemaFormatter instance

    throws InvalidArgumentException when the form formatter not exists

  • (string) getFormFormatterName () Browse code

    Gets the form formatter name that will be used to render the widget schema.

    returns The form formatter name

  • (array) getFormFormatters () Browse code

    Returns all the form formats defined for this form schema.

    returns An array of named form formats

  • (string) getGlobalErrors ($errors) Browse code

    $errors An array of errors

    Gets errors that need to be included in global errors.

    returns An HTML representation of global errors for the widget

  • (string) getHelp ($name) Browse code

    $name The field name

    Gets a text help by field name.

    returns The help text or an empty string if it is not defined

  • (array) getHelps () Browse code

    Sets the help texts.

    returns An array of help texts

  • (array) getJavaScripts () Browse code

    Gets the JavaScript paths associated with the widget.

    returns An array of JavaScript paths

  • (string) getLabel ($name = null) Browse code

    $name The field name (required - the default value is here because PHP do not allow signature changes with inheritance)

    Gets a label by field name.

    returns The label name or an empty string if it is not defined

    throws InvalidArgumentException when you try to get a label for a none existing widget

  • (array) getLabels () Browse code

    Gets the labels.

    returns An array of label names

  • (string) getNameFormat () Browse code

    Gets the format string for the name HTML attribute.

    returns The format string

  • getParent () Browse code

    Gets the parent widget schema.

    returns The parent widget schema

  • (array) getPositions () Browse code

    Gets the positions of the fields.


    The field positions are only used when rendering the schema with ->render().

    returns An ordered array of field names

  • (array) getStylesheets () Browse code

    Gets the stylesheet paths associated with the widget.

    returns An array of stylesheet paths

  • moveField ($field, (constant) $action, $pivot = null) Browse code

    $field The field name to move
    $action The action (see above for all possible actions)
    $pivot The field name used for AFTER and BEFORE actions

    Moves a field in a given position


    Available actions are:

    * sfWidgetFormSchema::BEFORE * sfWidgetFormSchema::AFTER * sfWidgetFormSchema::LAST * sfWidgetFormSchema::FIRST

    throws InvalidArgumentException when field not exist

  • (bool) needsMultipartForm () Browse code

    Returns true if the widget schema needs a multipart form.

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

  • (bool) offsetExists ($name) Browse code

    $name The field name

    Returns true if the schema has a field with the given name (implements the ArrayAccess interface).

    returns true if the schema has a field with the given name, false otherwise

  • offsetGet ($name) Browse code

    $name The field name

    Gets the field associated with the given name (implements the ArrayAccess interface).

    returns The sfWidget instance associated with the given name, null if it does not exist

  • offsetSet ($name, (sfWidget) $widget) Browse code

    $name The field name
    $widget An sfWidget instance

    Sets a field (implements the ArrayAccess interface).

    throws InvalidArgumentException when the field is not instance of sfWidget

  • offsetUnset ($name) Browse code

    $name field name

    Removes a field by name (implements the ArrayAccess interface).

  • (string) render ($name, $values = array(), $attributes = array(), $errors = array()) Browse code

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

    Renders the widget.

    returns An HTML representation of the widget

    throws InvalidArgumentException when values type is not array|ArrayAccess

  • (string) renderField ($name, $value = null, $attributes = array(), $errors = array()) Browse code

    $name The field name
    $value The field value
    $attributes An array of HTML attributes to be merged with the current HTML attributes
    $errors An array of errors for the field

    Renders a field by name.

    returns An HTML string representing the rendered widget

    throws InvalidArgumentException when the widget not exist

  • setDefault ($name, $value = null) Browse code

    $name The field name
    $value The default value (required - the default value is here because PHP do not allow signature changes with inheritance)

    Sets the default value for a field.

  • setDefaultFormFormatterName ($name) Browse code

    $name New default formatter name

    Sets the generic default formatter name used by the class. If you want all of your forms to be generated with the format, you can do it in a project or application configuration class:


    class ProjectConfiguration extends sfProjectConfiguration
    {
    public function setup()
    {
    sfWidgetFormSchema::setDefaultFormFormatterName('list');
    }
    }

  • setDefaults ($values) Browse code

    $values The default values for the widget

    Sets the default values for the widget.

  • setFormFormatterName ($name) Browse code

    $name The form formatter name

    Sets the form formatter name to use when rendering the widget schema.

  • setHelp ($name, $help) Browse code

    $name The field name
    $help The help text

    Sets a help text.

  • setHelps ($helps) Browse code

    $helps An array of help texts

    Sets the help texts to render for each field.

  • setLabel ($name, $value = null) Browse code

    $name The field name
    $value The label name (required - the default value is here because PHP do not allow signature changes with inheritance)

    Sets a label.

    throws InvalidArgumentException when you try to set a label on a none existing widget

  • setLabels ($labels) Browse code

    $labels An array of label names

    Sets the label names to render for each field.

  • setNameFormat ($format) Browse code

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

    Sets the format string for the name HTML attribute.


    If you are using the form framework with symfony, do not use a reserved word in the name format. If you do, symfony may act in an unexpected manner.

    For symfony 1.1 and 1.2, the following words are reserved and must NOT be used as the name format:

    * module (example: module[%s])
    * action (example: action[%s])

    However, you CAN use other variations, such as actions[%s] (note the s).

    throws InvalidArgumentException when no %s exists in the format

  • setParent ($parent = null) Browse code

    $parent

    Sets the parent widget schema.

  • setPositions ($positions) Browse code

    $positions An ordered array of field names

    Sets the positions of the fields.

    throws InvalidArgumentException when not all fields set in $positions

  • __clone () Browse code

  • __construct ($fields = null, $options = array(), $attributes = array(), $labels = array(), $helps = array()) Browse code

    $fields Initial fields
    $options An array of options
    $attributes An array of default HTML attributes
    $labels An array of HTML labels
    $helps An array of help texts

    Constructor.


    The first argument can be:

    * null * an array of sfWidget instances

    Available options:

    * name_format: The sprintf pattern to use for input names
    * form_formatter: The form formatter name (table and list are bundled)

    throws InvalidArgumentException when the passed fields not null or array