sfFormI18nNumberPlugin - 0.9.3

I18n-Number validator and widget

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

sfFormI18nNumberPlugin

The sfFormI18nNumberPlugin is a symfony plugin that provides an widget and validator for internationalized numbers.

Installation

  • Install the plugin

    $ symfony plugin:install sfFormI18nNumberPlugin
    
  • Clear you cache

    $ symfony cc
    

Use of the Validator and Widget

After you create in your schema a number-field with type double, float or decimal, change your form as follows:

before

    [php]
    public function configure()
    {
      // widgets
      $this->setWidgets(array(
        'number' => new sfWidgetFormInput(),
      ));

      // validators
      $this->setValidators(array(
        'number' => new sfValidatorNumber(),
      ));
    }

after

    [php]
    public function configure()
    {
      // widgets
      $this->setWidgets(array(
        'number' => new sfWidgetFormI18nNumber(),
      ));

      // validators
      $this->setValidators(array(
        'number' => new sfValidatorI18nNumber(),
      ));
    }

Configuration

The widget and the validator takes the culture to recognize, convert and display numbers from the user-session. If this is not possible or you want to use a different culture than the culture of the user session, you can set a option.

    [php]
      // widgets
      $this->setWidgets(array(
        'number' => new sfWidgetFormI18nNumber(array('culture' => 'fr')),
      ));

      // validators
      $this->setValidators(array(
        'number' => new sfValidatorI18nNumber(array('culture' => 'fr')),
      ));

TODO

  • tbd