Author: annis
Date: 2010-03-31 10:21:35 +0200 (Wed, 31 Mar 2010)
New Revision: 28908

Modified:
   plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/README
   
plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/lib/form/ahBaseFormDoctrine.class.php
Log:
added the option 'newFormAfterExistingRelations' to make it possible to display 
the empty form below the related objects

Modified: plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/README
===================================================================
--- plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/README  2010-03-31 
08:20:11 UTC (rev 28907)
+++ plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/README  2010-03-31 
08:21:35 UTC (rev 28908)
@@ -73,14 +73,15 @@
       ...
       $this->embedRelations(array(
         'Repositories' => array(
-          'considerNewFormEmptyFields' => array('name', 'repo_path', 
'repo_username', 'repo_password'),
-          'noNewForm' => true,
-          'newFormLabel' => 'New repository!!!', 
-          'newFormClass' => 'ahIntranetSubversionRepositoryNewForm',
-          'newFormClassArgs' => array(array('sf_user' => 
$this->getOption('sf_user'))),
-          'displayEmptyRelations' => false,
-          'formClass' => 'ahIntranetSubversionRepositoryEmbeddedForm',
-          'formClassArgs' => array(array('ah_add_delete_checkbox' => false, 
'another_form_option' => ...))
+          'considerNewFormEmptyFields'    => array('name', 'repo_path', 
'repo_username', 'repo_password'),
+          'noNewForm'                     => true,
+          'newFormLabel'                  => 'New repository!!!', 
+          'newFormClass'                  => 
'ahIntranetSubversionRepositoryNewForm',
+          'newFormClassArgs'              => array(array('sf_user' => 
$this->getOption('sf_user'))),
+          'displayEmptyRelations'         => false,
+          'formClass'                     => 
'ahIntranetSubversionRepositoryEmbeddedForm',
+          'formClassArgs'                 => 
array(array('ah_add_delete_checkbox' => false, 'another_form_option' => ...)),
+          'newFormAfterExistingRelations' => false
         ),
         '...' => array(
           ...
@@ -143,7 +144,7 @@
     You don't need to worry about the first one (the model object) because 
this is always null for the new form. If you want to pass some more options to 
the related form object (like the user object to avoid using sfContext) just 
follow the example above.
     I could have changed this (because I implemented it) but I don't want to 
confuse the developer because when you look at the option `formClassArgs` below 
it's the same mechanism and I can't change that short of copying the whole 
embedRelation method over to the ahBaseFormDoctrine class, thereby losing the 
chance to automatically get upstream bugfixes. :)
   
-  * `formClass` (string, not required): the form class to use for the existing 
related objects. 
+  * `formClass` (string, not required): the form class to use for the existing 
related objects.
   
   * `formClassArgs` (array of arrays, not required): form class options to 
pass to the existing related objects form class on instantiation
     As of version 1.1 it's not necessary to create a separate form class for 
the existing related forms to display the delete checkbox.
@@ -175,7 +176,9 @@
     This works because we're calling the plugin's event handler method.
     This either returns the form so it added the delete checkbox and the 
validator and you can act on that, or it returns false and you don't act on 
that. Neat and tidy. :)
   
-  * `displayEmptyRelations` (boolean, not required): set this to true (false 
is the default) if you want to check for existing related objects yourself. 
This can be done in the form template and is useful if you want to let the user 
know that 'There are no related repositories yet.'. The default is just not 
displaying anything in this case, which works for me. :)
+  * `displayEmptyRelations` (boolean, not required): set this option to true 
(false is the default) if you want to check for existing related objects 
yourself. This can be done in the form template and is useful if you want to 
let the user know that 'There are no related repositories yet.'. The default is 
just not displaying anything in this case, which works for me. :)
+  
+  * `newFormAfterExistingRelations` (boolean, not required): set this option 
to true to display the empty form to add new related objects below the existing 
related objects
 
 ## Questions, bugs, feature requests? ##
 

Modified: 
plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/lib/form/ahBaseFormDoctrine.class.php
===================================================================
--- 
plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/lib/form/ahBaseFormDoctrine.class.php
   2010-03-31 08:20:11 UTC (rev 28907)
+++ 
plugins/ahDoctrineEasyEmbeddedRelationsPlugin/trunk/lib/form/ahBaseFormDoctrine.class.php
   2010-03-31 08:21:35 UTC (rev 28908)
@@ -86,6 +86,11 @@
       {
         unset($this[$relationName]);
       }
+      
+      if (isset($relations[$relationName]['newFormAfterExistingRelations']) || 
$relations[$relationName]['newFormAfterExistingRelations'] && 
isset($this['new_'.$relationName]))
+      {
+        $this->getWidgetSchema()->moveField('new_'.$relationName, 
sfWidgetFormSchema::AFTER, $relationName);
+      }
     }
     
     $this->getEventDispatcher()->disconnect('form.post_configure', 
array($this, 'listenToFormPostConfigureEvent'));
@@ -132,7 +137,7 @@
           }
           
           if ($emptyFields === count($keys['considerNewFormEmptyFields'])) {
-            sfContext::getInstance()->getLogger()->info('Dropping relation 
:'.$relationName);
+            //sfContext::getInstance()->getLogger()->info('Dropping relation 
:'.$relationName);
             unset($values['new_'.$relationName], $this['new_'.$relationName]);
           }
         }

-- 
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.

Reply via email to