方法:
~~~
tpl_form_color($id,$func_name)
~~~
参数描述:
| 参数 | 名称 | 变量类型 |
| --- | --- | --- |
| id | 表单id | string |
|input_id| input_id | string |
|value| 默认值 | string |
|style_css| input额外样式 | string |
代码示例:
~~~
<?php echo tpl_form_color('colors','test-form-input'); ?>
<script>
layui.use('colorpicker', function(){
var $ = layui.$
,colorpicker = layui.colorpicker;
//表单赋值
colorpicker.render({
elem: '#colors'
,color: '#1c97f5'
,done: function(color){
$('#test-form-input').val(color);
}
});
});
</script>
~~~
效果图:
![](https://git.kancloud.cn/repos/caike_/wq_frame/raw/b46bdc3ca04f2c2d269b313cae88d5a7ca837c14/images/%E9%A2%9C%E8%89%B2%E9%80%89%E5%8F%96%E5%99%A8.png?access-token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1ODc0MDg0NTIsImlhdCI6MTU4NzM2NTI1MiwicmVwb3NpdG9yeSI6ImNhaWtlX1wvd3FfZnJhbWUiLCJ1c2VyIjp7InVzZXJuYW1lIjoieWhsMTgiLCJuYW1lIjoiTXJZZTU4NjkiLCJlbWFpbCI6IjU1NTg1MTkwQHFxLmNvbSIsInRva2VuIjoiNzE1MTdkYjM3ODBkMjIwNjI3NTk5ZTIzNGU0YThmOTYiLCJhdXRob3JpemUiOnsicHVsbCI6dHJ1ZSwicHVzaCI6dHJ1ZSwiYWRtaW4iOnRydWV9fX0.J8UpRlTnE5Y5M6P7EkjuqpLGrCv3SEJs3zdcT_SFAGw)