2017 © Pedro Peláez
 

symfony1-plugin dc-reloaded-form-extra-plugin

A set of useful extra widgets, validators, modules and other handy stuff for your symfony 1 projects

image

desarrollo-cespi/dc-reloaded-form-extra-plugin

A set of useful extra widgets, validators, modules and other handy stuff for your symfony 1 projects

  • Friday, December 27, 2013
  • by ncuesta
  • Repository
  • 7 Watchers
  • 0 Stars
  • 2 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

dcReloadedFormExtraPlugin

The dcReloadedFormExtraPlugin adds some useful extra widgets, validators, modules, etc., (*1)

Installation

  • Via composer:
{
  "require": {
    "desarrollo-cespi/dc-reloaded-form-extra-plugin": "dev-master"
  }
}
  • Or using git, from source., (*2)

  • Enable the plugin in your proyect configuration, (*3)

// in config/ProjectConfiguration.class.php add:
$this->enablePlugin("dcReloadedFormExtraPlugin");
  • Clear the cache

Widgets

pmWidgetFormPropelChoiceOrCreate

The pmWidgetFormPropelChoiceOrCreate extends the functionality provided by the sfWidgetFormPropelChoice, adding a link that opens a new window, allowing the user to create an object of the widget's model. Then, that object is available for being selected., (*4)

Usage

Use it as you use the sfWidgetFormPropelChoice, except for the following new parameters:, (*5)

  • url
  • new_label: The link's label. Defaults to New
  • ws_url

Enable the dc_ajax module., (*6)

Note: jQuery is required., (*7)

pmWidgetFormDoctrineChoiceOrCreate

The pmWidgetFormDoctrineChoiceOrCreate is the doctrine version of the pmWidgetFormPropelChoiceOrCreate. So, use it as you use the pmWidgetFormPropelChoiceOrCreate., (*8)

mtWidgetFormPlain

The mtWidgetFormPlain provides a way for showing plain values in the forms., (*9)

Usage
$this->widgetSchema["some_field"] = new mtWidgetFormPlain(array("add_hidden_input" => true));

For more options, take a look at the widget's doc comments., (*10)

dcWidgetFormAjaxDependence

This widget is used with select widgets filtering values depending on the selection made in observed widget. Supose widget A11 observing A1 widget changes, that observes A widget changes. In this case, you can have the following scenarios: * The form will save A, A1 and A11 values * The form will only sava A11 values (A and A1 will be used only for filtering purpose), (*11)

For the first case, just use the widget as it is. But for the second case, you will need to do some trick inside the form implementation:, (*12)

if (!$this->getObject()->isNew())
{
  $a11Object=$this->getObject()->getA11();
  $this->setDefault('a1_id',$a11Object->getA1Id());
  $this->setDefault('a_id',$b111->getB11()->getA1()->getAId());
}
Usage
$w = new sfWidgetFormInput();
$this->widgetSchema["some_field"] = new dcWidgetFormAjaxDependence(array(
  "dependant_widget" => $w,
  "observe_widget_id" => "some_form_some_field",
  "get_observed_value_callback" => array(get_class($this), "getValueForUpdate")
));

And then you must implement the getValueForUpdate method., (*13)

dcWidgetFormPropelAjaxDependence

Same as dcWidgetFormAjaxDependence, except that retrieves objects from Propel classes., (*14)

dcWidgetFormJQueryActivator

Based on dcWidgetFormJQueryDependence. It enables or disables the widget when another changes and a given condition evaluates to true., (*15)

mtWidgetFormPlain

The mtWidgetFormPlain displays a plain value., (*16)

Usage
$this->setWidget("some_field", new mtWidgetFormPlain());

dcWidgetFormChangeForCredentials

The dcWidgetFormChangeForCredentials displays one of two widgets depending on user's credentials., (*17)

Usage
$this->setWidget("some_field", new dcWidgetFormChangeForCredentials(new array(
  "credentials" => array(array("admin", "some_credential")),
  "widget_without_credentials" => new mtWidgetFormPlain(),
  "widget_with_credentials" => new sfWidgetFormInput()
)));

mtWidgetFormPartial

The mtWidgetFormPartial displays a partial., (*18)

Usage
$this->setWidget("partial", new mtWidgetFormPartial(array(
  "module" => "some_module",
  "partial" => "some_partial",
  "form" => $this
));

pmWidgetFormSelectJQueryAutocomplete

The pmWidgetFormSelectJQueryAutocomplete displays an autocomplete based on a select tag. This widget is basically a renderer, so it can be used as the renderer of a sfWidgetFormChoice, sfWidgetFormPropelChoice, etc., (*19)

jquery ui is required., (*20)

Usage
$this->getWidget("city_id")->setOption("renderer_class", "pmWidgetFormSelectJQueryAutocomplete");

pmWidgetFormJQuerySearch

The pmWidgetFormJQuerySearch displays an input text with search capabilities., (*21)

Usage
$this->setWidget("some_field") = new pmWidgetFormJQuerySearch(array(
  "url" => "@url_that_performs_the_search"
));

The jquery_search.js provides a javascript class with functions for displaying the results. See the example of a pmWidgetFormPropelJQuerySearch., (*22)

pmWidgetFormPropelJQuerySearch

The pmWidgetFormJQuerySearch displays an input text with search capabilities over propel objects., (*23)

Usage
$this->setWidget("some_field_id", new pmWidgetFormPropelJQuerySearch(array(
  "model" => "SomeField",
  "column" => "some_column"
)));

mtWidgetFormInputDate

The mtWidgetFormInputDate displays an input text for selecting dates. Must be validated with mtValidatorDateString and jquery and jqueryui are REQUIRED., (*24)

Usage
$this->setWidget("date", new mtWidgetFormInputDate());

mtWidgetFormEmbed

Widgets that embeds a dinamic number of forms. This widget only does the 'view' part. The saving and deleting of new and previous object has to be done manually., (*25)

mtWidgetFormCuil

Represents an Argetine CUIL/CUIT, (*26)

alWdigetFormTimepicker

Represents an Hour or also an Hour range., (*27)

This widget is a wrapper for a jQueryUITimepicker (http://fgelinas.com/code/timepicker/)., (*28)

Usage

The javascript widget can be configured in many ways, so you could define an associative array of key -> value (available options defined on author page or on this widget implementantion) to give values to it. Also, it allows to create ingle or range time values., (*29)

For a single time value all you need is:, (*30)

$this->setWidget("single_hour", new alWidgetFormTimepicker(array('config' => array('jquery_widget_option_key' => 'jquery_widget_option_value'))));

For a range time value:, (*31)

$this->setWidget("range_hour", new alWidgetFormTimepicker(array('config' => array('jquery_widget_option_key' => 'jquery_widget_option_value'), 'enable_timerange' => true)));

Note: remember than this widget uses the alValidatorTimepicker validator, and it should be configured wheter the value is single or range., (*32)

Check for in the validator section for further explanation on this matters., (*33)

Validators

mtValidatorDateString

Validates dates represented as strings., (*34)

alValidatorTimepicker

Validates single or range hour as strings., (*35)

It accepts an option called enable_timerange (by default set to false), that when its set to true, will be expecting a string that looks like this: "HH:MM-HH:MM". Otherwise, it will validate a single value like "HH:MM"., (*36)

Range value, (*37)

$this->setValidator("range_hour", new alValidatorTimepicker(array('enable_timerange' => true)));

Single value, (*38)

$this->setValidator("single_hour", new alValidatorTimepicker(array('enable_timerange' => false)));

or, (*39)

$this->setValidator("single_hour", new alValidatorTimepicker());

mtValidatorCuil

Validates a CUIL/CUIT from a String, (*40)

mtValidatorCuilExtended

Validates a CUIL/CUIT from a string made by mtWidgetFormCuil, (*41)

Usage
$this->setValidator("date", new mtValidatorDateString());

Form auto-initialization

This plugin provides form classes (which extends sfFormPropel and sfFormFilterPropel) that auto-initializes forms., (*42)

You just have to change the super class of the BaseFormPropel (and BaseFormFilterPropel) in order to use this functionality., (*43)

abstract class BaseFormPropel extends pmFormPropel
{
}

and, (*44)

abstract class BaseFormPropel extends pmFormFilterPropel
{
}

These clases uses the plugin's widgets and validators to initialize widgets and validators automatically: * unsets created_at and updated_at fields * uses mtWidgetFormInputDate for date widgets * replaces fields named "attachment" with sfWidgetFormInputFile * hides created_by and updated_by fields, (*45)

  • uses mtValidatorDateString for date validators
  • uses sfValidatorFile for fields named "attachment"

For developers

  • If you need to create ajax actions use the dc_ajax module.

TODO

pmWidgetFormPropelChoiceOrCreate

  • Add more of the sfWidgetFormPropelChoice parameters to the getPropelChoices action (and getDoctrineChoices).

The Versions

27/12 2013

dev-master

9999999-dev

A set of useful extra widgets, validators, modules and other handy stuff for your symfony 1 projects

  Sources   Download

MIT

The Requires

 

by Desarrollo CeSPI