Habari\FormControlTextMulti::pre_out PHP Метод

pre_out() публичный Метод

Return the HTML/script required for this control. Do it only once.
public pre_out ( ) : string
Результат string The HTML/javascript required for this control.
    public function pre_out()
    {
        $out = '';
        if (!FormControlTextMulti::$outpre) {
            FormControlTextMulti::$outpre = true;
            if (is_array($this->value)) {
                $fieldcount = count($this->value);
            } else {
                $fieldcount = 0;
            }
            // translatable strings
            // very bad practice but the below code is just horrible to read already and heredoc does not support method calls
            $removeitem = _t('Remove item');
            $remove = _t('[remove]');
            $removethisitem = _t('Remove this item?');
            $out .= <<<JSCODE
\t\t\t\t<script type="text/javascript">
\t\t\t\tcontrols.textmulti = {
\t\t\t\t\tadd: function(e, controlname){
\t\t\t\t\t\t\$(e).before('<div><input type="text" name="' + controlname + '[]"> <a href="#" onclick="return controls.textmulti.remove(this);" title="{$removeitem}" class="textmulti_remove">{$remove}</a></div>');
\t\t\t\t\t\treturn false;
\t\t\t\t\t},
\t\t\t\t\tremove: function(e) {
\t\t\t\t\t\tvar item = \$(e).prev();
\t\t\t\t\t\tif (confirm("{$removethisitem} " + item.val())) {
\t\t\t\t\t\t\titem.parent().remove();
\t\t\t\t\t\t}
\t\t\t\t\t\treturn false;
\t\t\t\t\t},
\t\t\t\t}
\t\t\t\t</script>
JSCODE;
        }
        return $this->controls_js($out);
    }
FormControlTextMulti