Issue #91 resolved

getAppend() bug in BootInput

Anonymous created an issue

function getAppend() called after rendering main input element and htmlOptions['append'], htmlOptions['appendOptions'] not unseted , so if we set in htmlOptions['appendOptions'] array with 2 and more elements - we will receive error, for example,

{{{

!php

echo $form->textFieldRow($model,'username',array('append'=>'<i class="icon-user"></i>','appendOptions'=>array('id'=>'checkuser','title'=>'Click for reload data'),'maxlength'=>20));

}}}

for solving this bug - add in class BootInput private variable for saving appendOptions in function getPrepend() and unset appendOptions in this function - before rendering base input element.

example : {{{

!php

abstract class BootInput extends CInputWidget { ........... private $_appendopt=array(); ........ protected function getPrepend() { if ($this->hasAddOn()) { if (isset($this->htmlOptions['prependOptions'])) { $htmlOptions = $this->htmlOptions['prependOptions']; unset($this->htmlOptions['prependOptions']); } else $htmlOptions = array(); if (isset($this->htmlOptions['appendOptions'])) { $this->_appendopt = $this->htmlOptions['appendOptions']; unset($this->htmlOptions['appendOptions']); }

        if (isset($htmlOptions['class']))
            $htmlOptions['class'] .= ' add-on';
        else
            $htmlOptions['class'] = 'add-on';

        $classes = $this->getInputContainerCssClass();
        ob_start();
        echo '<div class="'.$classes.'">';
        if (isset($this->htmlOptions['prepend']))
        {
            $this->_addon = true;             
            echo CHtml::tag('span', $htmlOptions, $this->htmlOptions['prepend']);
            unset($this->htmlOptions['prepend']);
        }
        return ob_get_clean();
    }
    else
        return '';
}

protected function getAppend() { if ($this->hasAddOn()) {

            $htmlOptions = $this->_appendopt;

        if (isset($htmlOptions['class']))
            $htmlOptions['class'] .= ' add-on';
        else
            $htmlOptions['class'] = 'add-on';

        ob_start();
        if (isset($this->htmlOptions['append']))
        {
            $this->_addon = true;

                echo CHtml::tag('span', $htmlOptions, $this->htmlOptions['append']);

            unset($this->htmlOptions['append']);
        }
        echo '</div>';
        return ob_get_clean();
    }
    else
        return '';
}

}}}

thanks for attention Donna Insolita

Comments (3)

  1. Log in to comment