Author: sid.gbf
Date: 2010-03-15 18:13:11 +0100 (Mon, 15 Mar 2010)
New Revision: 28533

Modified:
   
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form.php
   
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form_field.php
   
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/lib/helper/JavascriptAdminHelper.php
Log:
Updates



Modified: 
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form.php
===================================================================
--- 
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form.php
 2010-03-15 14:37:51 UTC (rev 28532)
+++ 
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form.php
 2010-03-15 17:13:11 UTC (rev 28533)
@@ -1,4 +1,4 @@
-[?php use_helper('JavascriptAdmin'); ?]
+[?php use_helper('JavascriptBase', 'JavascriptAdmin'); ?]
 [?php form_event_handlers($form); ?]
 [?php use_stylesheets_for_form($form) ?]
 [?php use_javascripts_for_form($form) ?]

Modified: 
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form_field.php
===================================================================
--- 
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form_field.php
   2010-03-15 14:37:51 UTC (rev 28532)
+++ 
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form_field.php
   2010-03-15 17:13:11 UTC (rev 28533)
@@ -1,7 +1,24 @@
-[?php if ($field->isPartial()): ?]
+[?php $force_show = isset($force_show); ?]
+[?php if (!$force_show && $field->isPartial()): ?]
   [?php include_partial('<?php echo $this->getModuleName() ?>/'.$name, 
array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? 
$attributes->getRawValue() : $attributes)) ?]
-[?php elseif ($field->isComponent()): ?]
+[?php elseif (!$force_show && $field->isComponent()): ?]
   [?php include_component('<?php echo $this->getModuleName() ?>', $name, 
array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? 
$attributes->getRawValue() : $attributes)) ?]
+[?php elseif (!$force_show && !$field->isReal() && (get_class($form[$name]) == 
'sfFormFieldSchema')): ?]
+  [?php echo $form[$name]->renderHiddenFields(); ?]
+  [?php $eform = $form[$name]; ?]
+  [?php foreach ($eform as $ename => $efield): ?]
+    [?php if ((isset($eform[$ename]) && $eform[$ename]->isHidden()) || 
(!isset($eform[$ename]) && $efield->isReal())) continue ?]
+    [?php include_partial('<?php echo $this->getModuleName() ?>/form_field', 
array(
+      'name'       => $ename,
+      'attributes' => array(),
+      'label'      => '',
+      'help'       => '',
+      'form'       => $eform,
+      'field'      => $efield,
+      'force_show' => true,
+      'class'      => 'sf_admin_form_row 
sf_admin_'.strtolower($efield->getWidget()->getOption('type')).' 
sf_admin_form_field_'.$ename,
+    )) ?]
+  [?php endforeach; ?]
 [?php else: ?]
   <div class="[?php echo $class ?][?php $form[$name]->hasError() and print ' 
errors' ?]">
     [?php echo $form[$name]->renderError() ?]

Modified: 
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/lib/helper/JavascriptAdminHelper.php
===================================================================
--- 
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/lib/helper/JavascriptAdminHelper.php
    2010-03-15 14:37:51 UTC (rev 28532)
+++ 
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/lib/helper/JavascriptAdminHelper.php
    2010-03-15 17:13:11 UTC (rev 28533)
@@ -1,6 +1,6 @@
 <?php
   function getDefaultHint() {
-    return __(sfConfig::get('app_default_hint', '<em>Clique aqui para definir 
um valor</em>'));
+    return '<em>'.__(sfConfig::get('app_default_hint', 'Clique aqui para 
definir um valor')).'</em>';
   }
 
   function content_to_view(sfFormField $field, $attributes, $help) {
@@ -20,16 +20,7 @@
   function form_event_handlers($form) {
     include_jquery();
     $command = 'jQuery(document).ready(function () {'."\r\n";
-    foreach($form as $fieldName => $field) {
-      if($field->isHidden())
-        continue;
-      $command .= '  
if(document.getElementById("'.$field->renderId().'_temp")) {' . "\r\n";
-      $command .= '    jQuery("#'.$field->renderId().'_temp").change( 
function() { reset_function(); update_values("'.$field->renderId().'") } );' . 
"\r\n";
-      $command .= '  } else {' . "\r\n";
-      $command .= '    jQuery("#'.$field->renderId().'").blur( function() { 
reset_function(); update_values("'.$field->renderId().'") } );' . "\r\n";
-      $command .= '  }' . "\r\n";
-      $command .= '  jQuery("#'.$field->renderId().'_view").click( function() 
{ switch_field("'.$field->renderId().'") } );' . "\r\n";
-    }
+    $command .= _process_form($form);
     $command .= '  reset_function();'."\r\n";
     $command .= '});'."\r\n";
     $command .= _form_hide_fields_function();
@@ -37,8 +28,32 @@
     $command .= _form_reset_function();
     $command .= _form_switch_function();
     $command .= _form_update_values_function();
+
     echo javascript_tag($command);
   }
+  function _process_form($form) {
+    $command = '';
+    foreach($form as $fieldName => $field) {
+      if($field->isHidden())
+        continue;
+      if(get_class($field) == 'sfFormFieldSchema') {
+        $command .= _process_form($field);
+      } else {
+        $command .= _generate_functions_for_field($fieldName, $field);
+      }
+    }
+    return $command;
+  }
+  function _generate_functions_for_field($fieldName, $field) {
+    $command = '';
+    $command .= '  if(document.getElementById("'.$field->renderId().'_temp")) 
{' . "\r\n";
+    $command .= '    jQuery("#'.$field->renderId().'_temp").change( function() 
{ reset_function(); update_values("'.$field->renderId().'") } );' . "\r\n";
+    $command .= '  } else {' . "\r\n";
+    $command .= '    jQuery("#'.$field->renderId().'").blur( function() { 
reset_function(); update_values("'.$field->renderId().'") } );' . "\r\n";
+    $command .= '  }' . "\r\n";
+    $command .= '  jQuery("#'.$field->renderId().'_view").click( function() { 
switch_field("'.$field->renderId().'") } );' . "\r\n";
+    return $command;
+  }
   function _form_hide_fields_function() {
     return 'function hide_all_fields() {
   jQuery(".content_edit").hide();
@@ -72,22 +87,25 @@
   } else {
     newValue = jQuery("#"+fieldName).val();
   }
-  if(newValue == "") {
+  if(newValue == null) {
     newValue = jQuery("#"+fieldName+"_edit > .help").html();
   }
   jQuery("#"+fieldName+"_view > .help").html(newValue);
 
 }'."\r\n";
   }
+/*if(!function_exists('javascript_tag')) {
   function javascript_tag($content)
   {
     return content_tag('script', javascript_cdata_section($content), 
array('type' => 'text/javascript'));
   }
-
+}
+if(!function_exists('javascript_cdata_section')) {
   function javascript_cdata_section($content)
   {
     return "\n//".cdata_section("\n$content\n//")."\n";
   }
+}*/
   function include_jquery() {
     $jquery = sfConfig::get('app_jquery_path', '/jquery.js');
     use_javascript($jquery);

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