在项目中会有很多用到这种配置窗口的地方,提供多种选项,input,textarea,select,radio,上传等组件,点击右上角保存会把数据提交到服务器
在php里面调用的话,比如:
//参见:./__project__/class/controller/foreground/Example.class.php/ui_window_xml
R_window_xml('./example/example.xml',url_build('ui_window_xml_1'),$data);
这种都是用xml文件定义的,里面可以运行php代码,比如下面,参见:./example/example.xml
<module>
<name>example</name>
<params>
<group title='输入框类'>
<section title='x' folded='false'>
<param formtype='hidden' name='input_0000' label='输入框_隐藏' description=''>
一个隐藏的参数/error-2611
</param>
<param formtype='readonly' name='input_0001' label='输入框_只读' description=''>
一个只读的参数/error-1324
</param>
</section>
<section title='x' folded='false'>
<param formtype='text' name='input_0002' label='输入框_input' description=''>
一个默认值/error-3126
</param>
<param formtype='textarea' name='input_0003' label='输入框_textarea' description=''>
</param>
</section>
</group>
<group title='选项类'>
<section title='x' folded='false'>
<param formtype='select' name='select_0000' label='选项_select' description='' >
<option value='0' selected='selected'>select_A</option>
<option value='1'>select_B</option>
<option value='2'>select_C</option>
<option value='3'>select_D</option>
</param>
<param formtype='radio' name='select_0001' label='选项_radio' description='' >
<option value='0' selected='selected'>radio_A</option>
<option value='1'>radio_B</option>
<option value='2'>radio_C</option>
<option value='3'>radio_D</option>
</param>
<param formtype='checkbox' name='select_0002' label='选项_checkbox' description='php生成选项示例' >
<?php
$temp=range('A', 'Z');
foreach($temp as $k=>$v)
{
echo '<option value=\''.$k.'\' >checkbox_'.$v.'</option>';
}
?>
</param>
</section>
</group>
<group title='文件上传'>
<section title='x' folded='false'>
<param description='参数描述示例' formtype='xmluploadfile' label='上传_图片' name='file_00' uploadfile_file_exts='<?php echo impd(\Prjconfig::file_pic_exts);?>' uploadfile_file_maxsize='<?php echo 2*datasize_1mb;?>' >
</param>
<param description='' formtype='xmluploadfile' label='上传_文件' name='file_11' uploadfile_file_exts='doc,docx,pdf,zip,rar,txt' uploadfile_file_maxsize='<?php echo 10*datasize_1mb;?>' >
</param>
</section>
</group>
</params>
</module>
因为大多数情况下,我们和后台进行数据交互,无非也就那么几种形式,上传文件就算是比较复杂的了,如果像传统的方式,要写个form里面还要写input啥的,比较麻烦,做成通用的xml文件定义的话,可以有效减少工作量