Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save snakewa/417043 to your computer and use it in GitHub Desktop.

Select an option

Save snakewa/417043 to your computer and use it in GitHub Desktop.
# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- ahDoctrineEasyEmbeddedRelationsPlugin/lib/form/ahBaseFormDoctrine.class.php
+++ ahDoctrineEasyEmbeddedRelationsPlugin/lib/form/ahBaseFormDoctrine.class.php
@@ -30,7 +30,8 @@
'newFormsContainerForm' => null, // pass BaseForm object here or we will create ahNewRelationsContainerForm
'newRelationButtonLabel' => '+',
'newRelationAddByCloning' => true,
- 'newRelationUseJSFramework' => 'jQuery'
+ 'newRelationUseJSFramework' => 'jQuery',
+ 'father_key' => null
);
protected function addDefaultRelationSettings(array $settings)
@@ -374,7 +375,7 @@
*/
private function embeddedFormFactory($relationName, array $relationSettings, Doctrine_Relation $relation, $formLabel = null)
{
- $newFormObject = $this->embeddedFormObjectFactory($relationName, $relation);
+ $newFormObject = $this->embeddedFormObjectFactory($relationName, $relation , $relationSettings['father_key']);
$formClass = empty($relationSettings['newFormClass']) ? $relation->getClass().'Form' : $relationSettings['newFormClass'];
$formArgs = empty($relationSettings['newFormClassArgs']) ? array() : $relationSettings['newFormClassArgs'];
$r = new ReflectionClass($formClass);
@@ -408,13 +409,17 @@
* @param Doctrine_Relation $relation
* @return Doctrine_Record
*/
- private function embeddedFormObjectFactory($relationName, Doctrine_Relation $relation)
+ private function embeddedFormObjectFactory($relationName, Doctrine_Relation $relation , $father_key = null)
{
if (Doctrine_Relation::MANY === $relation->getType())
{
$newFormObjectClass = $relation->getClass();
$newFormObject = new $newFormObjectClass();
- $newFormObject[get_class($this->getObject())] = $this->getObject();
+
+ if(!$father_key){
+ $father_key = get_class($this->getObject());
+ }
+ $newFormObject[$father_key] = $this->getObject();
} else
{
$newFormObject = $this->getObject()->$relationName;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment