Author: annis
Date: 2010-05-01 15:08:47 +0200 (Sat, 01 May 2010)
New Revision: 29333
Modified:
plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/README
plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/lib/form/ahBaseFormDoctrine.class.php
plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/web/js/ahDoctrineEasyEmbeddedRelationsPlugin.jQuery.js
Log:
Merge branch 'master' into HEAD
Modified: plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/README
===================================================================
--- plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/README 2010-05-01
10:50:04 UTC (rev 29332)
+++ plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/README 2010-05-01
13:08:47 UTC (rev 29333)
@@ -41,9 +41,9 @@
{
...
}
-
+
* Publish the plugin assets
-
+
symfony plugin:publish-assets
* Clear your cache
@@ -86,6 +86,7 @@
'formClass' =>
'ahIntranetSubversionRepositoryEmbeddedForm',
'formClassArgs' =>
array(array('ah_add_delete_checkbox' => false, 'another_form_option' => ...)),
'newFormAfterExistingRelations' => false,
+ 'formFormatter' => null,
'multipleNewForms' => true,
'newFormsInitialCount' => 2,
'newFormsContainerForm' => null, // pass BaseForm object
here or we will create ahNewRelationsContainerForm
@@ -190,16 +191,18 @@
* `newFormAfterExistingRelations` (boolean, not required): set this option
to true to display the empty form to add new related objects below the existing
related objects
+ * `formFormatter` (string, not required): class name of form formatter for
all forms embedding the relation forms
+
* `multipleNewForms` (boolean, not required): set this option to true if you
want to have multiple new related object forms
* `newFormsInitialCount` (integer, not required, default: 1): number of new
object forms initially displayed (you may insert/delete those forms dynamically
using JavaScript, all submitted subforms will be processed and validated.)
* `newFormsContainerForm` (form object, not required): if not passed, plugin
will create custom ahNewRelationsContainerForm form with a single
`ahAddRelation` button below the new relation form(s)
-
+
* `newRelationButtonLabel` (string, not required, default: '+'): label for
the `ahAddRelation` new relation button; the setting is used only when the
`newFormsContainerForm` option is empty.
* `newRelationAddByCloning` (boolean, not required, default: true): Should
the plugin add new relation forms by cloning them client-side (with
JavaScript). If set to false, you should add the behaviour yourself to the
`ahAddRelation` form button. The setting is used only when the
`newFormsContainerForm` option is empty.
-
+
* `newRelationUseJSFramework` (string, not required, default: 'jQuery'): the
JavaScript framework that should handle the client-side logic of the
`ahAddRelation` new relation button to dynamically add new forms in the
browser. There is currently only a jQuery version available but a MooTools
version is on my TODO list. :)
## Questions, bugs, feature requests? ##
Modified:
plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/lib/form/ahBaseFormDoctrine.class.php
===================================================================
---
plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/lib/form/ahBaseFormDoctrine.class.php
2010-05-01 10:50:04 UTC (rev 29332)
+++
plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/lib/form/ahBaseFormDoctrine.class.php
2010-05-01 13:08:47 UTC (rev 29333)
@@ -24,6 +24,7 @@
'formClassArgs' => array(),
'displayEmptyRelations' => false,
'newFormAfterExistingRelations' => false,
+ 'formFormatter' => null,
'multipleNewForms' => false,
'newFormsInitialCount' => 1,
'newFormsContainerForm' => null, // pass BaseForm object here or we
will create ahNewRelationsContainerForm
@@ -57,7 +58,7 @@
if ($relationSettings['multipleNewForms']) // allow multiple new
forms for this relation
{
$newFormsCount = $relationSettings['newFormsInitialCount'];
-
+
$subForm = $this->newFormsContainerFormFactory($relationSettings,
$containerName);
for ($i = 0; $i < $newFormsCount; $i++)
{
@@ -78,15 +79,23 @@
}
}
}
-
+
$formClass = $relationSettings['formClass'];
$formArgs = array_merge(
- $relationSettings['formClassArgs'],
+ $relationSettings['formClassArgs'],
array(array('ah_add_delete_checkbox' => true))
);
-
+
$this->embedRelation($relationName, $formClass, $formArgs);
+ if ($relationSettings['formFormatter']) { // switch formatter
+ $widget = $this[$relationName]->getWidget()->getWidget();
+ $widget->setFormFormatterName($relationSettings['formFormatter']);
+ // not only we have to change formatter name
+ // but also recreate schemadecorator as there is no setter for
decorator in sfWidgetFormSchemaDecorator :(
+ $this->widgetSchema[$relationName] = new
sfWidgetFormSchemaDecorator($widget,
$widget->getFormFormatter()->getDecoratorFormat());
+ }
+
/*
* Unset the relation form(s) if:
* (1. One-to-many relation and there are no related objects yet (count
of embedded forms is 0) OR
@@ -370,6 +379,7 @@
$formArgs = empty($relationSettings['newFormClassArgs']) ? array() :
$relationSettings['newFormClassArgs'];
$r = new ReflectionClass($formClass);
+ /* @var $newForm sfFormObject */
$newForm = $r->newInstanceArgs(array_merge(array($newFormObject),
array($formArgs)));
$newFormIdentifiers =
$newForm->getObject()->getTable()->getIdentifierColumnNames();
foreach ($newFormIdentifiers as $primaryKey)
@@ -429,13 +439,17 @@
$subForm = new ahNewRelationsContainerForm(
array('new_relation' => $relationSettings['newRelationButtonLabel']),
array(
- 'containerName' => $containerName,
+ 'containerName' => $containerName,
'addByCloning' => $relationSettings['newRelationAddByCloning'],
'useJSFramework' => $relationSettings['newRelationUseJSFramework']
)
);
}
+ if ($relationSettings['formFormatter']) {
+
$subForm->getWidgetSchema()->setFormFormatterName($relationSettings['formFormatter']);
+ }
+
unset($subForm[$subForm->getCSRFFieldName()]);
return $subForm;
}
Modified:
plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/web/js/ahDoctrineEasyEmbeddedRelationsPlugin.jQuery.js
===================================================================
---
plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/web/js/ahDoctrineEasyEmbeddedRelationsPlugin.jQuery.js
2010-05-01 10:50:04 UTC (rev 29332)
+++
plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/web/js/ahDoctrineEasyEmbeddedRelationsPlugin.jQuery.js
2010-05-01 13:08:47 UTC (rev 29333)
@@ -18,16 +18,16 @@
if (matches = nameRe.exec(this.name)) { //
check if its name contains [container][number]
// if so, increase the number in field
name
this.name =
this.name.replace(nameRe,'[' + container + '][' + (parseInt(matches[1],10)+1) +
']');
- if (this.id) { // and id
- this.id =
this.id.replace('_'+container+'_'+matches[1]+'_',
-
'_'+container+'_'+(parseInt(matches[1],10)+1)+'_');
- }
}
+ if (matches = idRe.exec(this.id)) { // check if
its name contains _container_number_
+ // if so, increase the number in label
for attribute
+ this.id = this.id.replace(idRe,'_' +
container + '_' + (parseInt(matches[1],10)+1) + '_');
+ }
$(this).trigger('change.ah'); // trigger
onchange event just for a case
}).end();
// fix labels
- $(this).find('label:for').each(function() {
+ $(this).find('label[for]').each(function() {
var matches;
if (matches = idRe.exec($(this).attr('for'))) {
// check if its name contains _container_number_
// if so, increase the number in label
for attribute
@@ -36,7 +36,7 @@
});
// increase the number in first <th>
- $header = $(this).find('th').eq(0);
+ $header = $(this).children('th').eq(0);
if ($header.text().match(/^\d+$/)) {
$header.text(parseInt($header.text(),10) + 1);
}
@@ -52,12 +52,18 @@
$('.ahAddRelation').click(function() {
// find last row of my siblings (each row represents a subform)
- $row = $(this).parents('tr').siblings(':last');
+ $row = $(this).parents('tr,li').siblings('tr:last,li:last');
// clone it, increment the fields and insert it below,
additionally triggering events
- $row.clone()
+ $row.trigger('beforeclone.ah');
+ var $newrow = $row.clone(true);
+ $row.trigger('afterclone.ah')
+
+ $newrow
.incrementFields($(this).attr('rel'))
-
.trigger('beforeadd.ah').insertAfter($row).trigger('afteradd.ah');
+ .trigger('beforeadd.ah')
+ .insertAfter($row)
+ .trigger('afteradd.ah');
//use events to further modify the cloned row like this
// $(document).bind('beforeadd.ah', function(event) {
$(event.target).hide() /* event.target is cloned row */ });
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.