Select :: renderControlOptions: Bitrix method

      
<?php 
//  Bitrix\Bizproc\BaseType\Select :: renderControlOptions()
//  /dist/bitrix/modules/bizproc/lib/basetype/select.php:284

    
public static function renderControlOptions(FieldType $fieldType$callbackFunctionName$value)
    {
        
$options = static::getFieldOptions($fieldType);

        
$str '';
        foreach (
$options as $k => $v)
        {
            if ((string)
$k !== (string)$v)
                
$str .= '['.$k.']'.$v;
            else
                
$str .= $v;

            
$str .= "\n";
        }

        
$rnd randString();
        
$renderResult '<textarea id="WFSFormOptionsX'.$rnd.'" rows="5" cols="30">'.htmlspecialcharsbx($str).'</textarea><br />';
        
$renderResult .= Loc::getMessage('BPDT_SELECT_OPTIONS1').'<br />';
        
$renderResult .= Loc::getMessage('BPDT_SELECT_OPTIONS2').'<br />';
        
$renderResult .= '<script type="text/javascript">
                function WFSFormOptionsXFunction'
.$rnd.'()
                {
                    var result = {};
                    var i, id, val, str = document.getElementById("WFSFormOptionsX'
.$rnd.'").value;

                    var arr = str.split(/[\r\n]+/);
                    var p, re = /\[([^\]]+)\].+/;
                    for (i in arr)
                    {
                        str = arr[i].replace(/^\s+|\s+$/g, \'\');
                        if (str.length > 0)
                        {
                            id = str.match(re);
                            if (id)
                            {
                                p = str.indexOf(\']\');
                                id = id[1];
                                val = str.substr(p + 1);
                            }
                            else
                            {
                                val = str;
                                id = val;
                            }
                            result[id] = val;
                        }
                    }

                    return result;
                }
                </script>'
;
        
$renderResult .= '<input type="button" onclick="'.htmlspecialcharsbx($callbackFunctionName)
            .
'(WFSFormOptionsXFunction'.$rnd.'())" value="'.Loc::getMessage('BPDT_SELECT_OPTIONS3').'">';

        return 
$renderResult;
    }