<case value="tags">
    <div class="form-group item_{$[type]form.name} {$[type]form.extra.class}">
        <label class="left control-label">{$[type]form.title}：</label>
        <div class="right">
            <input type="text" id="[type]{$group_k}_tag_{$[type]k}" class="form-control" name="{$[type]form.name}" value="{$[type]form.value}" {$[type]form.extra.attr}>
            <link rel="stylesheet" type="text/css" href="__PUBLIC__/libs/jquery_tokeninput/css/token-input.css">
            <link rel="stylesheet" type="text/css" href="__PUBLIC__/libs/jquery_tokeninput/css/token-input-bootstrap.css">
            <script type="text/javascript" src="__PUBLIC__/libs/jquery_tokeninput/js/jquery.tokeninput.min.js" charset="utf-8"></script>
            <script type="text/javascript">
                $(function(){
                    //标签自动完成
                    var tags = $('#[type]{$group_k}_tag_{$[type]k}'), tagsPre = [];
                    if (tags.length > 0) {
                        var items = tags.val().split(','), result = [];
                        for (var i = 0; i < items.length; i ++) {
                            var tag = items[i];
                            if (!tag) {
                                continue;
                            }
                            tagsPre.push({
                                id      :   tag,
                                title   :   tag
                            });
                        }
                    }
                    tags.tokenInput("<?php echo U(MODULE_NAME.'/Tag/search'); ?>",{
                        propertyToSearch    :   'title',
                        tokenValue          :   'title',
                        searchDelay         :   0,
                        tokenLimit          :   10,
                        preventDuplicates   :   true,
                        animateDropdown     :   true,
                        allowFreeTagging    :   true,
                        hintText            :   '请输入标签名',
                        noResultsText       :   '此标签不存在, 按回车创建',
                        searchingText       :   "查找中...",
                        prePopulate         :   tagsPre,
                        theme               :   'bootstrap',
                        onAdd: function (item){ //新增系统没有的标签时提交到数据库
                            $.post("<?php echo U(MODULE_NAME.'/Tag/add'); ?>", {'title': item.title});
                        }
                    });
                });
            </script>
        </div>
    </div>
</case>
