search

Home  >  Q&A  >  body text

Front desk - php form automatically built

Thinkphp framework is often used for project development. Each functional module basically requires addition, deletion, modification and query operations. The pages are basically the same, except for the different form fields. However, each module needs to be modified one by one each time. Adding fields and names to the edit list page requires a lot of repetitive work and is very time-consuming.
Sample code:

        <p class="ibox-content">

            <table class="table table-bordered">
                <thead>
                    <tr class="success">
                        <th>id</th>
                        <th>权限名称</th>
                        <th>模块名称</th>
                        <th>控制器名称</th>
                        <th>方法名称</th>
                        <th>上级权限id</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                <foreach name="lists" item="vo" >
                    <tr class="">
                        <td>{$vo.id}</td>
                        <td>{$vo.auth_name}</td>
                        <td>{$vo.module}</td>
                        <td>{$vo.controller}</td>
                        <td>{$vo.action}</td>
                        <td>{$vo.pid}</td>
                        <td><a href="{:U('Rbac/Auth/editC',['id'=>$vo['id']])}" class="btn btn-w-m btn-info">编辑</a>&nbsp<a href="{:U('Rbac/Auth/delC',['id'=>$vo['id']])}" class="btn btn-w-m btn-danger" onclick="return confirm('确定要删除吗?');">删除</a></td>
                    </tr>
                </foreach>

                </tbody>
            </table>

How to automatically generate dynamic forms and lists based on database tables.
How do you deal with this part of the repetitive work when doing projects? Is there any better way or front-end framework that can handle this problem? Best Can you provide a reference code? Thank you all.
I found an idea: to directly generate a form based on the model (database table) configuration, write a configuration file for one database table?

某草草某草草2730 days ago945

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-07-05 09:58:04

    I changed it manually

    reply
    0
  • 大家讲道理

    大家讲道理2017-07-05 09:58:04

    yii2 officially comes with gii, which can easily generate models, controllers, grud, etc.

    reply
    0
  • ringa_lee

    ringa_lee2017-07-05 09:58:04

    I don’t like GII too much, long-term use is not conducive to improving the coding ability

    reply
    0
  • Cancelreply