Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed issue #6494: Non-existing attribute fields are shown
  • Loading branch information
c-schmitz committed Aug 20, 2012
1 parent 0c6606e commit 9751a5e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 14 additions & 0 deletions application/controllers/admin/tokens.php
Expand Up @@ -744,8 +744,11 @@ function addnew($iSurveyId)

// add attributes
$attrfieldnames = Survey::model()->findByPk($iSurveyId)->tokenAttributes;
$aTokenFieldNames=Yii::app()->db->getSchema()->getTable("{{tokens_$iSurveyId}}",true);
$aTokenFieldNames=array_keys($aTokenFieldNames->columns);
foreach ($attrfieldnames as $attr_name => $desc)
{
if(!in_array($attr_name,$aTokenFieldNames)) continue;
$value = Yii::app()->getRequest()->getPost($attr_name);
if ($desc['mandatory'] == 'Y' && trim($value) == '')
$this->getController()->error(sprintf($clang->gT('%s cannot be empty'), $desc['description']));
Expand Down Expand Up @@ -2269,6 +2272,17 @@ function _handletokenform($iSurveyId, $subaction, $iTokenId="")
}

$thissurvey = getSurveyInfo($iSurveyId);
$aAdditionalAttributeFields = $thissurvey['attributedescriptions'];
$aTokenFieldNames=Yii::app()->db->getSchema()->getTable("{{tokens_$iSurveyId}}",true);
$aTokenFieldNames=array_keys($aTokenFieldNames->columns);
foreach ($aAdditionalAttributeFields as $sField=>$aData)
{
if (in_array($sField,$aTokenFieldNames))
{
$aData['attrfieldnames'][$sField]=$aData;
}
}

$aData['thissurvey'] = $thissurvey;
$aData['surveyid'] = $iSurveyId;
$aData['subaction'] = $subaction;
Expand Down
3 changes: 1 addition & 2 deletions application/views/admin/token/tokenform.php
Expand Up @@ -150,10 +150,9 @@

<?php
// now the attribute fieds
$attrfieldnames = $thissurvey['attributedescriptions'];
foreach ($attrfieldnames as $attr_name => $attr_description)
{
?>
?>
<li>
<label for='<?php echo $attr_name; ?>'><?php echo $attr_description['description'] . ($attr_description['mandatory'] == 'Y' ? '*' : '') ?>:</label>
<input type='text' size='55' id='<?php echo $attr_name; ?>' name='<?php echo $attr_name; ?>' value='<?php
Expand Down

0 comments on commit 9751a5e

Please sign in to comment.