dcReloadedFormExtraPlugin
The dcReloadedFormExtraPlugin adds some useful extra widgets, validators, modules,
etc.
Installation
svn installation:
$ svn co http://svn.symfony-project.com/plugins/dcReloadedFormExtraPlugin/trunk plugins/dcReloadedFormExtraPlugin
install as a plugin:
$ ./symfony pl:i dcReloadedFormExtraPlugin
Enable the plugin in your proyect configuration (only if installed through svn)
// in config/ProjectConfiguration.class.php add:
$this->enablePlugin("dcReloadedFormExtraPlugin");
clear the cache
$ ./symfony cc
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.
Usage
Use it as you use the sfWidgetFormPropelChoice, except for the following new
parameters:
- url
- new_label: The link's label. Defaults to New
- ws_url
Enable the dc_ajax module.
Note: jQuery is required.
pmWidgetFormDoctrineChoiceOrCreate
The pmWidgetFormDoctrineChoiceOrCreate is the doctrine version of the
pmWidgetFormPropelChoiceOrCreate. So, use it as you use the
pmWidgetFormPropelChoiceOrCreate.
mtWidgetFormPlain
The mtWidgetFormPlain provides a way for showing plain values in the forms.
Usage
$this->widgetSchema["some_field"] = new mtWidgetFormPlain(array("add_hidden_input" => true));
For more options, take a look at the widget's doc comments.
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)
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:
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.
dcWidgetFormPropelAjaxDependence
Same as dcWidgetFormAjaxDependence, except that retrieves objects from Propel
classes.
mtWidgetFormPlain
The mtWidgetFormPlain displays a plain value.
Usage
$this->setWidget("some_field", new mtWidgetFormPlain());
dcWidgetFormChangeForCredentials
The dcWidgetFormChangeForCredentials displays one of two widgets depending on
user's credentials.
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.
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.
jquery ui is required.
Usage
$this->getWidget("city_id")->setOption("renderer_class", "pmWidgetFormSelectJQueryAutocomplete");
pmWidgetFormJQuerySearch
The pmWidgetFormJQuerySearch displays an input text with search capabilities.
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.
pmWidgetFormPropelJQuerySearch
The pmWidgetFormJQuerySearch displays an input text with search capabilities
over propel objects.
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.
Usage
$this->setWidget("date", new mtWidgetFormInputDate());
Validators
mtValidatorDateString
Validates dates represented as strings.
Usage
$this->setValidator("date", new mtValidatorDateString());
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).