Author: jaimesuez
Date: 2010-04-19 17:32:16 +0200 (Mon, 19 Apr 2010)
New Revision: 29210
Modified:
plugins/sfDoctrineAjaxFormPlugin/lib/sfDoctrineAjaxFormPluginHelper.class.php
plugins/sfDoctrineAjaxFormPlugin/lib/widget/sfWidgetFormDinamicEmbeddedForm.class.php
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/actions/actions.class.php
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_autocomplete_with_embedded_forms_default.php
Log:
EMBEDDED FORMS:
Opciones
Initial_embedded: Cuantos embebidos vienen por default
Modified:
plugins/sfDoctrineAjaxFormPlugin/lib/sfDoctrineAjaxFormPluginHelper.class.php
===================================================================
---
plugins/sfDoctrineAjaxFormPlugin/lib/sfDoctrineAjaxFormPluginHelper.class.php
2010-04-19 15:00:05 UTC (rev 29209)
+++
plugins/sfDoctrineAjaxFormPlugin/lib/sfDoctrineAjaxFormPluginHelper.class.php
2010-04-19 15:32:16 UTC (rev 29210)
@@ -13,7 +13,7 @@
{
################################ FUNCIONES PARA EMBEDD FORMS DINAMICOS
########################################
- static public function configureDinamicEmbeddedForms( & $form)
+ static public function configureDinamicEmbeddedForms(& $form)
{
//obtenemos los "widget_name" de todos los dinamic embedded forms
$widget_names_dinamic_embedded_forms =
$form->getOption('widget_names_dinamic_embedded_forms');
@@ -29,6 +29,8 @@
$foreign_alias =
$form->getWidget($widget_name)->getOption('foreign_alias');
$module_relation =
$form->getWidget($widget_name)->getOption('module_relation');
$form_module_relation =
$form->getWidget($widget_name)->getOption('form_module_relation');
+ $initial_embedded =
$form->getWidget($widget_name)->getOption('initial_embedded');
+ $widget_model =
$form->getWidget($widget_name)->getOption('widget_model');
//Un formulario vacio hara de contenedor para todas los embedded forms
$objects_container_form = new sfForm();
@@ -58,11 +60,21 @@
}
}
+ //embebidas < initial_embedded -> Embebemos hasta completar
+ while ($count < $initial_embedded)
+ {
+ $object = new $widget_model();
+ $object->$module_relation = $form->getObject();
+ $object_form = new $form_class($object);
+ $object_form->unsetFields($unset);
+ $objects_container_form->embedForm($count++, $object_form);
+ }
+
$form->embedForm($embedded_name, $objects_container_form);
}
}
- public static function embedFormDinamic( & $form, $widget_name, $num,
$id_related_object, $taintedValues = null)
+ public static function embedFormDinamic(& $form, $widget_name, $num,
$id_related_object, $taintedValues = null)
{
$foreign_type = $form->getWidget($widget_name)->getOption('foreign_type');
$foreign_alias =
$form->getWidget($widget_name)->getOption('foreign_alias');
@@ -73,42 +85,42 @@
$set_module_relation = 'set' .
$form->getWidget($widget_name)->getOption('module_relation'); //setConyuge x ej
$form_module_relation =
$form->getWidget($widget_name)->getOption('form_module_relation'); //Conyuge x
ej
$set_form_module_relation = 'set' . $form_module_relation; //setConyuge x
ej
-
+
$related_object = $id_related_object > 0 ?
Doctrine::getTable($widget_model)->find($id_related_object) : new
$widget_model();
-
+
//la foreign key esta en el objeto contenedor , x ej feligres
if ($foreign_type == 'ONE-one')
{
$form->getObject()->$set_form_module_relation($related_object);
}
-
+
//la clave foranea esta en los dos objetos
elseif ($foreign_type == 'ONE-ONE')
{
$form->getObject()->$set_form_module_relation($related_object);
// $related_object->$set_module_relation($form->getObject()); #NO
FUNCIONA QUE SE SETEE LA CLAVE FORANEA AL EMBEDDED OBJECT
}
-
+
//se usa tabla de referencia
elseif ($foreign_type == "many-many")
{
$reference_object = $form->getObject()->$foreign_alias; //por ej
Padrinos
$reference_object[count($reference_object)] = $related_object;
}
-
+
//la clave foranea esta en el objeto embebido, x ej hijo (one-many)
else
{
$related_object->$set_module_relation($form->getObject());
}
-
+
//unseteamos los campos
$object_form = new $widget_form($related_object);
$object_form->unsetFields($unset);
-
+
//Empotramos el nuevo objeto en el contenedor
$form->getEmbeddedForm($embedded_name)->embedForm($num, $object_form);
-
+
//Volvemos a empotrar el contenedor
$form->embedForm($embedded_name, $form->getEmbeddedForm($embedded_name));
}
Modified:
plugins/sfDoctrineAjaxFormPlugin/lib/widget/sfWidgetFormDinamicEmbeddedForm.class.php
===================================================================
---
plugins/sfDoctrineAjaxFormPlugin/lib/widget/sfWidgetFormDinamicEmbeddedForm.class.php
2010-04-19 15:00:05 UTC (rev 29209)
+++
plugins/sfDoctrineAjaxFormPlugin/lib/widget/sfWidgetFormDinamicEmbeddedForm.class.php
2010-04-19 15:32:16 UTC (rev 29210)
@@ -12,7 +12,7 @@
$this->addRequiredOption('form_model');
$this->addOption('module', class_to_module($options["form_model"]));
- //traducción de (form_module_relation - module_relation) ->
foreign_relation
+ //traducción de "foreign_relation" = "form_module_relation" -
"module_relation"
$this->addRequiredOption('foreign_relation');
$foreign_relation = explode('-', $options['foreign_relation']);
$this->options["form_module_relation"] = $foreign_relation[0] == "none" ?
null : $foreign_relation[0];
Modified:
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/actions/actions.class.php
===================================================================
---
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/actions/actions.class.php
2010-04-19 15:00:05 UTC (rev 29209)
+++
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/actions/actions.class.php
2010-04-19 15:32:16 UTC (rev 29210)
@@ -155,20 +155,20 @@
{
$object->unlink("Padrinos", array($embedded_id));
$object->save();
- $html .= " - Unlink de relación many to many, al objeto relacionado
de id: $embedded_id";
+ $html .= " - Unlink de relacion many to many, al objeto relacionado de
id: $embedded_id";
}
}
else
{
if($embedded_object)
{
- if ($set_module_relation != 'set')
- {
- $embedded_object->$set_module_relation(null);
- }
+// if ($set_module_relation != 'set')
+// {
+// $embedded_object->$set_module_relation(null);
+// }
$embedded_object->delete();
- $html .= 'Se borró el objeto embebido de id ' . $embedded_id;
+ $html .= 'Se borro el objeto embebido de id ' . $embedded_id;
}
if($object)
@@ -178,7 +178,7 @@
$object->$set_form_module_relation(null); //similar a
$hijo->setFeligres(...);
}
$object->save();
- $html .= ' y se borro referencia foránea a él';
+ $html .= ' y se borro referencia foranea a el';
}
}
@@ -204,7 +204,7 @@
{
$object->unlink("Padrinos", array($embedded_id));
$object->save();
- $html .= " - Unlink de relación many to many, al objeto relacionado
de id: $embedded_id";
+ $html .= " - Unlink de relacion many to many, al objeto relacionado de
id: $embedded_id";
}
}
else
Modified:
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_autocomplete_with_embedded_forms_default.php
===================================================================
---
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_autocomplete_with_embedded_forms_default.php
2010-04-19 15:00:05 UTC (rev 29209)
+++
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_autocomplete_with_embedded_forms_default.php
2010-04-19 15:32:16 UTC (rev 29210)
@@ -10,6 +10,7 @@
<?php echo "numero embebidos: " . $form[$embedded_name]->count() ?>
<?php echo "maximo: " . $number_embedded ?>
+<?php echo "inicial: " . $initial_embedded ?>
<!--############################### BOTONES PARA AGREGAR Y FRASES
################################## -->
<div>
@@ -113,7 +114,6 @@
'credentials' => $credentials,
'thumbnail' => $thumbnail,
'create_partial' => $create_partial,
- "with_hide" => $with_hide,
));
?>
--
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.