CMS MADE SIMPLE FORGE

CGFeedback

 

[#8677] Custom fields are not sticky

avatar
Created By: Deleted User (deleteduser_11200)
Date Submitted: Mon Nov 26 12:22:17 -0500 2012

Assigned To:
Version: 1.5.10
CMSMS Version: None
Severity: Minor
Resolution: Fixed
State: Closed
Summary:
Custom fields are not sticky
Detailed Description:
=== Introduction ===

Currently I am setting up CGBlog with CGComments. 
In CGComments I have setup a custom field called 'extra'. 

I have set the title and comment field to required my Smarty tag looks like
this:

{CGFeedback action='default' policy='session' key1=$ccuser->loggedin()
key2=$item->id destpage=$canonical titlerequired='1' commentrequired='1'}

When making a mistake in the form or not entering the title or comments field I
get an error message saying some field is missing.

=== Problem ===

By making a mistake on the CGFeedback form fixed fields are sticky, but the
custom fields are not.

=== Why are custom fields not sticky? ===

When you take a look into 'CGFeedback/templates/orig_commentform_template.tpl'
you see {$field.value} is used to set the formvalue, so it's not the template.

  {* custom fields *}
  {if isset($fields)}
  {foreach from=$fields key='fieldid' item='field'}
  <div class="row" style="margin: 1em;">
    <div class="col30" style="float: left; width: 29%;">
      {$field.name}:
    </div>
    <div class="col70" style="float: left; width: 70%;">
    {if isset($field.input)}
      {$field.input}
    {elseif $field.type == 0 or $field.type == 1 }
<input type="text" name="{$actionid}field_{$fieldid}"
value="{$field.value}" size="{$field.attrib.length}"
maxlength="{$field.attrib.maxlength}"/>
    {elseif $field.type == 2}
{* text area fields should have an input... so this should never get
caled... but just in case *}
      <textarea name="{$actionid}field_{$fieldid}">{$field.value}</textarea>
    {elseif $field.type == 3}
      <select name="{$actionid}field_{$fieldid}">
        {html_options options=$field.attrib.options selected="{$field.value}"}
      </select>
    {elseif $field.type == 4}
<select multiple="multiple" size="4" name="{$actionid}field_{$fieldid}[]">
        {html_options options=$field.attrib.options selected="{$field.value}"}
      </select>
    {/if}
    </div>
  </div>
  {/foreach}
  {/if}

When you take a look into CGFeedback/action.default.php you see that only
fieldtype '2' (textarea) is made sticky:
  
  
453 if( count($tfields) ) {
454   $tmp = array_keys($tfields);
455   foreach( $tmp as $fid ) {
456     switch($tfields[$fid]['type']) {
457       case 2:
458     $val = $comment->get_field_by_id($fid);
459     if( $val == '' ) {
460       if( isset($tfields[$fid]['dfltcontent']) ) {
461         $val = $tfields[$fid]['defaultcontent'];
462       }
463     }
464     $tfields[$fid]['input'] =
465       $this->CreateTextArea(isset($tfields[$fid]['attrib']['usewysiwyg']) &&
$tfields[$fid]['attrib']['usewysiwyg'] == 1 &&
466                 $this->GetPreference('allow_comment_wysiwyg',0),
467                 $id,$val,'field_'.$tfields[$fid]['id']);
468     break;
469     }
470   }
471 }

=== Fix ===

I made a little correction to your script and now all custom field (types) are
sticky, hope this is helpful:


[arnoud@lama CGFeedback]$ diff -u ../action.default.orig ./action.default.php 
--- ../action.default.orig	2012-11-26 18:22:44.000000000 +0100
+++ ./action.default.php	2012-11-26 18:25:17.000000000 +0100
@@ -465,7 +465,10 @@
$this->CreateTextArea(isset($tfields[$fid]['attrib']['usewysiwyg']) &&
$tfields[$fid]['attrib']['usewysiwyg'] == 1 &&
 				$this->GetPreference('allow_comment_wysiwyg',0),
 				$id,$val,'field_'.$tfields[$fid]['id']);
-	break;
+	  	break;
+	  	
+		default: 
+			$tfields[$fid]['value'] = $comment->get_field_by_id($fid);
     }
   }
 }

Extra information:

Same as: http://dev.cmsmadesimple.org/bug/view/7479 but I a more recent version
so I filed another bug report.





  
  
  



History

Comments
avatar
Date: 2015-05-27 17:29
Posted By: Robert Campbell (calguy1000)

fixed in svn, thanks
      
Updates

Updated: 2017-02-22 12:56
state: Open => Closed

Updated: 2015-05-27 17:29
resolution_id: => 7
cmsms_version_id: 29828 => -1