phpcms如何自定义表单
自定义表单的步骤如下:
(1):打开后台,点击模块,找到表单向导,点击添加表单向导,出现下面的界面。
(2):接下来,我们需要介绍下上面图中的模板选择和js调用使用的模板这两个选项,对于模板选择的话,其实就是我们的表单的前台页面,js调用使用的模板表示提交表单之后执行的跳转操作,一般情况下,我们只需要切换模板选择部分内容就可以实现表单样式修改,js调用使用的模板不需要我们做任何操作,具体模板选择show.html与js调用使用的模板show_js.html存储在什么地方呢?
立即学习“PHP免费学习笔记(深入)”;
答案是phpcms\templates\default\formguide路径下,那么实际中,我们只需要切换模板选择即可,在此我自己定义一个show_message.html的文件,并将模板选择位置切换成我的show_message.html文件。
相关推荐:phpcms教程
(3):接下来就是我的show_message.html文件编写过程了,该文件的编写需要参考原先show.html写法,我们来看下show.html里面关于表单的部分是怎么写的。
<form method="post" action="?m=formguide&c=index&a=show&formid={$formid}&siteid=<?php echo $this->siteid;?>" name="myform" id="myform"> <table class="table_form" width="100%" cellspacing="0"> <tbody> {loop $forminfos_data $field $info} {if $info['formtype']=='omnipotent'} {loop $forminfos_data $_fm $_fm_value} {if $_fm_value['iscomnipotent']} {php $info['form'] = str_replace('{'.$_fm.'}',$_fm_value['form'],$info['form']);} {/if} {/loop} {/if} <tr> <th width="80">{if $info['star']} <font color="red">*</font>{/if} {$info['name']} </th> <td>{$info['form']} {$info['tips']}</td> </tr> {/loop} </tbody> </table> <input type="submit" name="dosubmit" id="dosubmit" value=" 提交 "> <input type="reset" value=" 取消 "></form>