问题:
创建自定义表单和字段。管理数据;
我正在使用PHP和Codeigniter创建CMS。 我的客户需要自己管理表单字段。因为它们可以改变......今天将是大约20个领域。但下个月将是23岁。
我知道如何制作逻辑来创建表单。 但是我如何管理数据呢?
序列化数据并保存在表格中的一个字段中,我认为没有帮助,因为,如何在表格中对序列化数据进行快速搜索/过滤?
有人已经遇到这个问题了吗?也许可以帮助我在这里建立一个小逻辑来获得一种工作方式。
以防万一有人问Codeigniter,我能做这样的事情:
$formData = $this->input->post();
得到这样的东西:
$formData = array(
[fieldName] = 'Value',
[fieldName2] = 'Value 2'
[fieldName3] = 'Value 3'
);
所以获取数据很容易。
答案 0 :(得分:1)
动态创建表单的表结构
frm_fields表
field_id
field_title (the title that appears beside the field on the form)
field_level (defines the level of the organisation at which the field is represented e.g. global or office level)
field_view (defines which view the field relates to in the erp system used by the business)
field_block (defines the block of fields it will appear in on the form)
field_technicalName
field_side (value is either 1 or 2 which defines whether it appears on the left or right of the 2 column block)
field_type (defines whether it is a text, select, checkbox field etc.)
field_length (defines the max character length of the field)
field_width (defines the size of the field as it appears on the form)
frm_active table
form_id (each form request will of course have a unique id)
field_id (foreign/primary key of the field from the table above)
field_value (the value they have entered for this field)
答案 1 :(得分:0)
要管理动态php表单,您可以添加一个新表来管理表单字段。该表将包含有关表单中字段的信息。由于您说它可以由用户更改,因此输入字段也可以更新。 例如: 表格表格: form_id,field_id,输入类型,验证,必填字段
然后根据表单值,您可以在php中管理表单提交。 即根据您的要求规范化表格结构。在php中你的for循环用于迭代每个输入。使用输入字段id作为表单中的名称。
答案 2 :(得分:0)