kmFormExtraPlugin - 0.9.0

Mootools Datepicker widget, Validators

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

kmFormExtraPlugin

The kmFormExtraPlugin packages useful validators, and widgets.

Installation

  • PEAR

    $ symfony plugin:install kmFormExtraPlugin
    $ symfony cache:clear
    
  • git

    $ git clone git://github.com/marfillaster/kmFormExtraPlugin.git plugins/kmFormExtraPlugin
    $ symfony cache:clear
    

Mootools Datepicker

This plugin provides kmWidgetFormMooToolsDate and kmWidgetFormMooToolsDateTime. It uses Mootools Datepicker for client-side datepicker widget.

kmWidgetFormMooToolsDateTime requires kmValidatorDateTimeCompact as validator.

  • installation

    $ git clone git://github.com/arian/mootools-datepicker.git plugins/kmFormExtraPlugin/web/mootools-datepicker        
    $ php symfony plugin:publish-assets
    
  • globally replace default date and datetime widgets

    class BaseForm extends sfFormSymfony
    {
      public function setup()
      {
    
        foreach($this as $name => $field)
        {
          $widget = $field->getWidget(); 
          if($widget instanceof sfWidgetFormDate)
          {
            $this->widgetSchema[$name] = new kmWidgetFormMooToolsDate();
          }
          if($widget instanceof sfWidgetFormDateTime)
          {
            $this->widgetSchema[$name] = new kmWidgetFormMooToolsDateTime();
            $this->validatorSchema[$name] = new kmValidatorDateTimeCompact(array('required' => false));
          }
          if($widget instanceof sfWidgetFormFilterDate)
          {
            $widget->setOption('from_date', new kmWidgetFormMooToolsDate());
            $widget->setOption('to_date', new kmWidgetFormMooToolsDate());
            $widget->setOption('template', '%from_date%%to_date%');
            $widget->setOption('with_empty', false);
          }
        }
    
        parent::setup();
      }
    }