Author: Jonathan.Wage
Date: 2010-01-28 06:20:46 +0100 (Thu, 28 Jan 2010)
New Revision: 27271

Added:
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/save_slotsSuccess.php
Removed:
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/edit_slotSuccess.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/preview_slotSuccess.php
Modified:
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/config/routing.yml
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/lib/Basesympal_edit_slotActions.class.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/_slot_editor.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_editor/templates/_editor.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/web/js/editor.js
   plugins/sfSympalPlugin/trunk/lib/sfSympalConfiguration.class.php
   plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php
Log:
[1.4][sfSympalPlugin][1.0] Refactoring slot saving to only require one request, 
implementing something to handle form validation errors when saving slots


Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/config/routing.yml
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/config/routing.yml
    2010-01-28 03:22:21 UTC (rev 27270)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/config/routing.yml
    2010-01-28 05:20:46 UTC (rev 27271)
@@ -1,43 +1,10 @@
-sympal_edit_content_slot:
-  url:   /edit_content_slot/:content_id/:id
-  param: { module: sympal_edit_slot, action: edit_slot }
-  class: sfDoctrineRoute
-  options:
-    model: sfSympalContentSlot
-    type: object
+sympal_save_content_slots:
+  url:   /save_content_slots/:content_id
+  param: { module: sympal_edit_slot, action: save_slots }
 
-sympal_save_content_slot:
-  url:   /edit_content_slot/:content_id/:id/save
-  param: { module: sympal_edit_slot, action: save_slot }
-  class: sfDoctrineRoute
-  options:
-    model: sfSympalContentSlot
-    type: object
-  requirements:
-    id: \d+
-    sf_method: [post]
-
-sympal_preview_content_slot:
-  url:   /preview_content_slot/:content_id/:id
-  param: { module: sympal_edit_slot, action: preview_slot }
-  class: sfDoctrineRoute
-  options:
-    model: sfSympalContentSlot
-    type: object
-  requirements:
-    id: \d+
-    sf_method: [post]
-
 sympal_change_content_slot_type:
-  url:   /change_content_slot/:content_id/:id
+  url:   /change_content_slot_type/:content_id/:id/:type
   param: { module: sympal_edit_slot, action: change_content_slot_type }
-  class: sfDoctrineRoute
-  options:
-    model: sfSympalContentSlot
-    type: object
-  requirements:
-    id: \d+
-    sf_method: [post]
 
 sympal_editor_links:
   url:   /editor/links

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/lib/Basesympal_edit_slotActions.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/lib/Basesympal_edit_slotActions.class.php
    2010-01-28 03:22:21 UTC (rev 27270)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/lib/Basesympal_edit_slotActions.class.php
    2010-01-28 05:20:46 UTC (rev 27271)
@@ -15,68 +15,60 @@
     $this->setLayout(false);
   }
 
-  protected function _getContentSlot(sfWebRequest $request)
+  public function executeChange_content_slot_type(sfWebRequest $request)
   {
-    $this->contentSlot = $this->getRoute()->getObject();
     $this->content = 
Doctrine_Core::getTable('sfSympalContent')->find($request->getParameter('content_id'));
+    $this->contentSlot = 
Doctrine_Core::getTable('sfSympalContentSlot')->find($request->getParameter('id'));
     $this->contentSlot->setContentRenderedFor($this->content);
+    $this->contentSlot->setType($request->getParameter('type'));
+    $this->contentSlot->save();
 
-    return $this->contentSlot;
-  }
-
-  protected function _getContentSlotForm(sfWebRequest $request)
-  {
-    $this->contentSlot = $this->_getContentSlot($request);
-
     $this->form = $this->contentSlot->getEditForm();
-
-    return $this->form;
   }
 
-  public function executeChange_content_slot_type(sfWebRequest $request)
+  public function executeSave_slots(sfWebRequest $request)
   {
-    $slotId = $request->getParameter('id');
-    $slot = $request->getParameter('sf_sympal_content_slot_'.$slotId);
+    $this->contentSlots = array();
+    $this->failedContentSlots = array();
+    $errors = array();
 
-    $this->contentSlot = $this->_getContentSlot($request);
-    $this->contentSlot->setType($slot['type']);
-    $this->contentSlot->save();
-
-    $this->form = $this->_getContentSlotForm($request);
-  }
-
-  public function executeEdit_slot(sfWebRequest $request)
-  {
-    $this->form = $this->_getContentSlotForm($request);
-  }
-
-  public function executeSave_slot(sfWebrequest $request)
-  {
-    $this->form = $this->_getContentSlotForm($request);
-
-    $this->form->bind($request->getParameter($this->form->getName()));
-    if ($this->form->isValid())
+    $content = 
Doctrine_Core::getTable('sfSympalContent')->find($request->getParameter('content_id'));
+    $slotIds = $request->getParameter('slots');
+    foreach ($slotIds as $slotId)
     {
-      $this->form->save();
+      $contentSlot = 
Doctrine_Core::getTable('sfSympalContentSlot')->find($slotId);
+      $contentSlot->setContentRenderedFor($content);
+      $form = $contentSlot->getEditForm();
+      $form->bind($request->getParameter($form->getName()));
+      if ($form->isValid())
+      {
+        if ($request->getParameter('preview'))
+        {
+          $form->updateObject();
+        } else {
+          $form->save();
+        }
+        $this->contentSlots[] = $contentSlot;
+      } else {
+        $this->failedContentSlots[] = $contentSlot;
+        foreach ($form as $name => $field)
+        {
+          if ($field->hasError())
+          {
+            $errors[$contentSlot->getName()] = $field->getError();
+          }
+        }
+      }
     }
 
-    $this->setTemplate('preview_slot');
-  }
-
-  public function executePreview_slot(sfWebRequest $request)
-  {
-    $this->form = $this->_getContentSlotForm($request);
-    $this->contentSlot->resetRenderCache();
-
-    $this->form->bind($request->getParameter($this->form->getName()));
-    if ($this->form->isValid())
+    $this->errorString = null;
+    if ($errors)
     {
-      $this->form->updateObject();
-
-      $this->setTemplate('preview_slot');
-    } else {
-      exit((string) $this->form);
-      $this->setTemplate('edit_slot');
+      $this->errorString = count($errors).' error'.(count($errors) > 1 ? 's' : 
null).' occurred:\n\n';
+      foreach ($errors as $name => $error)
+      {
+        $this->errorString .= ' * '.$name.': '.$error.'\n';
+      }
     }
   }
-}
+}
\ No newline at end of file

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/_slot_editor.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/_slot_editor.php
   2010-01-28 03:22:21 UTC (rev 27270)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/_slot_editor.php
   2010-01-28 05:20:46 UTC (rev 27271)
@@ -3,11 +3,7 @@
 <?php sympal_use_javascript('/sfSympalEditorPlugin/js/editor.js') ?>
 
 <div class="sympal_content_slot_editor sympal_form">
-  <?php echo jq_form_remote_tag(array(
-    'url' => 
url_for('@sympal_save_content_slot?content_id='.$contentSlot->getContentRenderedFor()->getId().'&id='.$contentSlot->getId()),
-    'update' => "#sympal_content_slot_".$contentSlot->getId()." .value"
-  )) ?>
-
+  <form>
     <?php if (!$contentSlot->is_column): ?>
       <a class="sympal_change_slot_type" onClick="return false;">>> <?php echo 
__('Change Slot Type') ?></a>
       <div class="sympal_change_slot_type_dropdown">

Deleted: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/edit_slotSuccess.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/edit_slotSuccess.php
       2010-01-28 03:22:21 UTC (rev 27270)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/edit_slotSuccess.php
       2010-01-28 05:20:46 UTC (rev 27271)
@@ -1 +0,0 @@
-<?php echo get_partial('sympal_edit_slot/slot_editor', array('form' => $form, 
'contentSlot' => $contentSlot)) ?>
\ No newline at end of file

Deleted: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/preview_slotSuccess.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/preview_slotSuccess.php
    2010-01-28 03:22:21 UTC (rev 27270)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/preview_slotSuccess.php
    2010-01-28 05:20:46 UTC (rev 27271)
@@ -1 +0,0 @@
-<?php echo $contentSlot->render() ?>
\ No newline at end of file

Added: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/save_slotsSuccess.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/save_slotsSuccess.php
                              (rev 0)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_edit_slot/templates/save_slotsSuccess.php
      2010-01-28 05:20:46 UTC (rev 27271)
@@ -0,0 +1,16 @@
+
+<?php /* Add red border around input and textareas of failed content slots */ 
?>
+<?php foreach ($failedContentSlots as $contentSlot): ?>
+  $('#sympal_content_slot_<?php echo $contentSlot->getId() ?> .editor input, 
#sympal_content_slot_<?php echo $contentSlot->getId() ?> .editor 
textarea').css('border', '1px solid red');
+<?php endforeach; ?>
+
+<?php /* Updated rendered value of successfully content slots and removed red 
border */ ?>
+<?php foreach ($contentSlots as $contentSlot): ?>
+  $('#sympal_content_slot_<?php echo $contentSlot->getId() ?> 
.value').html('<?php echo str_replace("\n", ' ', $contentSlot->render()) ?>');
+  $('#sympal_content_slot_<?php echo $contentSlot->getId() ?> .editor input, 
#sympal_content_slot_<?php echo $contentSlot->getId() ?> .editor 
textarea').css('border', '1px solid #ccc');
+<?php endforeach; ?>
+
+<?php /* Output the error string if errors occurred */ ?>
+<?php if ($errorString): ?>
+  alert('<?php echo $errorString ?>');
+<?php endif; ?>
\ No newline at end of file

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_editor/templates/_editor.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_editor/templates/_editor.php
   2010-01-28 03:22:21 UTC (rev 27270)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_editor/templates/_editor.php
   2010-01-28 05:20:46 UTC (rev 27271)
@@ -22,7 +22,10 @@
 
 <div class="sympal_inline_edit_bar_top_background"></div>
 
+<input type="hidden" id="sympal_base_url" value="<?php echo 
url_for('@homepage', 'absolute=true') ?>" />
+
 <?php if (isset($sf_sympal_content) && $sf_sympal_content): ?>
+  <input type="hidden" id="sympal_save_slots_url" value="<?php echo 
url_for('@sympal_save_content_slots?content_id='.$sf_sympal_content->getId()) 
?>" />
   <div class="sympal_inline_edit_bar_bottom_background"></div>
 <?php endif; ?>
 

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/web/js/editor.js
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/web/js/editor.js  
    2010-01-28 03:22:21 UTC (rev 27270)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/web/js/editor.js  
    2010-01-28 05:20:46 UTC (rev 27271)
@@ -1,9 +1,12 @@
-// TODO: This javascript sucks, but it works. Make it not suck but keep it 
working.
-
 var currentlyFocusedSympalEditor = null;
 
 $(function()
 {
+  // Top admin menu bar mouseover and mouseout events for dropdown menus
+  $('.sympal_inline_edit_admin_menu ul > li').bind('mouseover', 
sympalAdminMenuOpen);
+  $('.sympal_inline_edit_admin_menu ul > li').bind('mouseout', 
sympalAdminMenuClose);
+
+  // Content publishing fancybox
   $('#sympal_assets #sympal_ask_confirmation input.no').live('click', 
function() {
     $('#sympal_assets').load($('.toggle_sympal_assets').attr('rel'));
     return false;
@@ -28,6 +31,7 @@
     'hideOnContentClick': false,
   });
 
+  // Override the webdebug toolbar and how it is hidden and displayed
   $('#sfWebDebugBar a:first').click(function() {
     if ($('#sfWebDebugDetails').css('visibility') == 'visible')
     {
@@ -39,149 +43,141 @@
     return false;
   });
 
-  // Hide the inline edit bar buttons by default
-  // These are the Save and Preview buttons which will be shown when the user
-  // clicks Edit
-  $('.sympal_inline_edit_bar_buttons').hide();
-
+  // Toggle edit mode
   var editMode = $.cookie('sympal_inline_edit_mode');
 
   if (editMode == 'true')
   {
-    toggleSympalEditMode();
+    sympalEnableEditMode();
   }
 
-  // Function to toggle edit mode on and off
-  var enabled = false;
-  function toggleSympalEditMode(clicked)
-  {
-    enabled = enabled ? false : true;
-
-    $.cookie('sympal_inline_edit_mode', enabled ? 'true' : 'false');
-
-    if (clicked)
-    {
-      // Focus on the form element that was clicked to enable inline editing
-      $($(clicked).parent().get(0)).find('.editor input, .editor textarea, 
.editor select:first').focus();
-    }
-
-    // If the state is being enabled then lets change the inline edit bar 
buttons and link
-    if (enabled)
-    {
-      enabled = false;
-      $('.toggle_edit_mode').hide();
-      $('.sympal_inline_edit_bar_buttons').show();
-      $('.sympal_content_slot .editor').show();
-      $('.sympal_content_slot .value').hide()
-    } else {
-      $('.sympal_content_slot .editor').hide();
-      $('.sympal_content_slot .value').show()
-    }
-  }
-
-  // When an element with class="toggle_edit_mode" is clicked toggle edit mode
+  // When a input element with class="toggle_edit_mode" is clicked toggle edit 
mode
   $('input.toggle_edit_mode').click(function() {
-    toggleSympalEditMode(this);
+    sympalToggleEditMode(this);
   });
 
+  // When a span element with class="toggle_edit_mode" is double clicked 
toggle edit mode
   $('span.toggle_edit_mode').dblclick(function() {
-    toggleSympalEditMode(this);
+    sympalToggleEditMode(this);
   });
 
-  sympalSetupDropdownMenus();
-
   // Show the change slot type dropdown when class="sympal_change_slot_type" 
is clicked
   $('.sympal_change_slot_type').click(function() {
     $(this).siblings('.sympal_change_slot_type_dropdown').slideToggle();
   });
 
-  // Update the editor widget for this slot when the dropdown is changed
+  // Update the editor form for this slot when the dropdown is changed
   $('.sympal_change_slot_type_dropdown select').change(function() {
     var select = $(this);
     var form = $(this.form);
-    var url = form.attr('action').replace('edit', 'change').replace('/save', 
'');
-    form.ajaxSubmit({
-      url: url,
-      target: form.parents('.sympal_content_slot').find('.editor 
.sympal_content_slot_editor_form'),
-      success: 
select.parents('.sympal_change_slot_type_dropdown').slideToggle()
+    var type = select.val();
+    var slotId = form.parents('span').find('.content_slot_id').attr('value');
+    var contentId = form.parents('span').find('.content_id').attr('value');
+
+    var url = $('#sympal_base_url').attr('value') + 
'change_content_slot_type/' + contentId + '/' + slotId + '/' + type;
+
+    form.parents('.sympal_content_slot').find('.editor 
.sympal_content_slot_editor_form').load(url, function() {
+      select.parents('.sympal_change_slot_type_dropdown').slideToggle()
     });
   });
 
-  // Save all the slots on the page
+  // Save content slots
   $('.sympal_save_content_slots').click(function() {
-    sympalTinyMCETriggerSave();
-    
-    // Save each content slot form
-    $('.sympal_content_slot form').each(function() {
-      var form = $(this);
-      $(this).ajaxSubmit({
-        target: form.parents('.sympal_content_slot').find('.value')
-      });
-    });
-    // Toggle the editor and value states
-    $('.sympal_content_slot .editor').hide();
-    $('.sympal_content_slot .value').show();
-
-    // Update the inline edit bar buttons and links
-    $('.toggle_edit_mode').show();
-    $('.sympal_inline_edit_bar_buttons').hide();
-
-    $.cookie('sympal_inline_edit_mode', 'false');
-    sympalCloseAllDropdowns();
+    sympalSaveContentSlots();
   });
 
-  // Render a preview of all the slots
+  // Preview content slots
   $('.sympal_preview_content_slots').click(function() {
-    sympalTinyMCETriggerSave();
-    
-    // Submit each slot form to render a preview
-    $('.sympal_content_slot form').each(function() {
-      var form = $(this);
-      var url = form.attr('action').replace('edit', 
'preview').replace('/save', '');
-      $(this).ajaxSubmit({
-        url: url,
-        target: form.parents('.sympal_content_slot').find('.value')
-      });
-    });
-    // Toggle the editor and value states
-    $('.sympal_content_slot .editor').hide();
-    $('.sympal_content_slot .value').show();
-
-    // Update the inline edit bar buttons and links
-    $('.toggle_edit_mode').show();
-    $('.sympal_inline_edit_bar_buttons').hide();
-
-    $.cookie('sympal_inline_edit_mode', 'false');
-    sympalCloseAllDropdowns();
+    sympalSaveContentSlots(true);
   });
 
+  // Disable edit mode
   $('.sympal_disable_edit_mode').click(function() {
-    // Toggle the editor and value states
-    $('.sympal_content_slot .editor').hide();
-    $('.sympal_content_slot .value').show();
-
-    // Update the inline edit bar buttons and links
-    $('.toggle_edit_mode').show();
-    $('.sympal_inline_edit_bar_buttons').hide();
-
-    $.cookie('sympal_inline_edit_mode', 'false');
-    sympalCloseAllDropdowns();
-    $('#sfWebDebug').show();
+    sympalDisableEditMode();
   });
 
+  // Keep track of the currently focused editor
   $('.sympal_content_slot .editor input, .sympal_content_slot .editor 
textarea').focus(function() {
     currentlyFocusedSympalEditor = $(this);
   });
 
-  $('#sympal_close_menus').click(function() {
-    return false;
-  });
-
+  // Close all dropdowns with class="sympal_close_menu" is clicked
   $('.sympal_close_menu').live('click', function() {
     sympalCloseAllDropdowns();
   });
+
+  // Setup the sympal dropdown menu panels (assets and links)
+  sympalSetupDropdownMenus();
 });
 
+function sympalToggleEditMode(clicked)
+{
+  var editMode = $.cookie('sympal_inline_edit_mode');
+
+  if (clicked)
+  {
+    // Focus on the form element that was clicked to enable inline editing
+    $($(clicked).parent().get(0)).find('.editor input, .editor textarea, 
.editor select:first').focus();
+  }
+
+  // If the state is being enabled then lets change the inline edit bar 
buttons and link
+  if (editMode == 'true')
+  {
+    sympalDisableEditMode();
+  } else {
+    sympalEnableEditMode();
+  }
+}
+
+function sympalSaveContentSlots(preview)
+{
+  preview = typeof(preview) != 'undefined' ? preview : false;
+
+  sympalTinyMCETriggerSave();
+
+  var queryString;
+  $('.sympal_content_slot form').each(function() {
+    var form = $(this);
+    var slotId = form.parents('span').find('.content_slot_id').attr('value');
+    queryString = queryString + '&' + form.formSerialize() + '&slots[]=' + 
slotId;
+  });
+
+  var url = $('#sympal_save_slots_url').attr('value');
+  url = preview ? url + '?preview=1' : url;
+  $.post(url, queryString, function(response) {
+    // If response doesn't contain an alert( then we know no errors occurred
+    // so we can disable edit mode
+    if (response.indexOf('alert(') == -1)
+    {
+      sympalDisableEditMode();
+    }
+
+    eval(response);
+  });
+}
+
+function sympalDisableEditMode()
+{
+  $('.toggle_edit_mode').show();
+  $('.sympal_content_slot .value').show();
+  $('.sympal_inline_edit_bar_buttons').hide();
+  $('.sympal_content_slot .editor').hide();
+
+  $.cookie('sympal_inline_edit_mode', 'false');
+  sympalCloseAllDropdowns();
+}
+
+function sympalEnableEditMode()
+{
+  $('.toggle_edit_mode').hide();
+  $('.sympal_content_slot .value').hide()
+  $('.sympal_inline_edit_bar_buttons').show();
+  $('.sympal_content_slot .editor').show();
+
+  $.cookie('sympal_inline_edit_mode', 'true');
+}
+
+// Top admin menu bar
 var timeout    = 1000;
 var closetimer = 0;
 var sympalMenuItem = 0;
@@ -215,13 +211,6 @@
   }
 }
 
-$ (document).ready(function()
-{
-  $('.sympal_inline_edit_admin_menu ul > li').bind('mouseover', 
sympalAdminMenuOpen);
-});
-
-document.onclick = sympalAdminMenuClose;
-
 function sympalTinyMCETriggerSave()
 {
   tinyMCE.triggerSave();
@@ -320,4 +309,4 @@
   sympalSetupDropdownMenu('#sympal_dashboard', '.toggle_dashboard_menu');
   sympalSetupDropdownMenu('#sympal_assets', '.toggle_sympal_assets');
   sympalSetupDropdownMenu('#sympal_links', '.toggle_sympal_links');
-}
+}
\ No newline at end of file

Modified: plugins/sfSympalPlugin/trunk/lib/sfSympalConfiguration.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/sfSympalConfiguration.class.php    
2010-01-28 03:22:21 UTC (rev 27270)
+++ plugins/sfSympalPlugin/trunk/lib/sfSympalConfiguration.class.php    
2010-01-28 05:20:46 UTC (rev 27271)
@@ -109,7 +109,7 @@
     $this->initializeTheme();
 
     $this->_projectConfiguration->loadHelpers(array(
-      'Sympal', 'SympalContentSlot', 'SympalMenu', 'SympalPager', 'I18N', 
'Asset'
+      'Sympal', 'SympalContentSlot', 'SympalMenu', 'SympalPager', 'I18N', 
'Asset', 'Url', 'Partial'
     ));
 
     if ($this->isAdminModule())

Modified: plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php 
2010-01-28 03:22:21 UTC (rev 27270)
+++ plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php 
2010-01-28 05:20:46 UTC (rev 27271)
@@ -91,16 +91,18 @@
       return;
     }
 
+    $type = $contentSlot->type ? $contentSlot->type : 'Text';
+
     $widgetSchema = $form->getWidgetSchema();
     $validatorSchema = $form->getValidatorSchema();
 
     $contentSlotTypes = sfSympalConfig::get('content_slot_types', null, 
array());
-    $options = isset($contentSlotTypes[$contentSlot->type]) ? 
$contentSlotTypes[$contentSlot->type] : array();
+    $options = isset($contentSlotTypes[$type]) ? $contentSlotTypes[$type] : 
array();
 
-    $widgetClass = isset($options['widget_class']) ? $options['widget_class'] 
: 'sfWidgetFormSympal'.$contentSlot->type;
+    $widgetClass = isset($options['widget_class']) ? $options['widget_class'] 
: 'sfWidgetFormSympal'.$type;
     $widgetOptions = isset($options['widget_options']) ? 
$options['widget_options'] : array();
 
-    $validatorClass = isset($options['validator_class']) ? 
$options['validator_class'] : 'sfValidatorFormSympal'.$contentSlot->type;
+    $validatorClass = isset($options['validator_class']) ? 
$options['validator_class'] : 'sfValidatorFormSympal'.$type;
     $validatorOptions = isset($options['validator_options']) ? 
$options['validator_options'] : array();
 
     $widgetSchema['value'] = new $widgetClass($widgetOptions);

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