[英]How to manage data from Dynamically Created Form with PHP
問題:
創建自定義表單和字段。 管理數據;
我正在使用PHP和Codeigniter創建CMS。 我的客戶將需要自行管理表單字段。 因為它們可以改變,所以今天大約有20個領域。 但是下個月將是23日。
我知道如何建立表格的邏輯。 但是我該如何管理數據?
我認為對數據進行序列化並保存在表的一個字段中不會有幫助,因為我如何在序列化數據中對表進行快速搜索/過濾?
有人已經遇到這個問題了嗎? 也許可以幫助我在這里建立一個小的邏輯,以找到一種工作方式。
以防萬一有人問到Codeigniter,我可以做這樣的事情:
$formData = $this->input->post();
並得到這樣的東西:
$formData = array(
[fieldName] = 'Value',
[fieldName2] = 'Value 2'
[fieldName3] = 'Value 3'
);
因此獲取數據非常容易。
此表結構為動態創建的表單
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表
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)
要管理動態php表單,您可以添加一個用於管理表單字段的新表。 該表將包含有關表單中字段的信息。 由於您說過可以由用戶更改,因此輸入字段也可以更新。 例如:表格表格:form_id,field_id,輸入類型,驗證,必填字段
然后,基於表單表值,您可以在php中管理表單提交。 即根據您的要求規范化表結構。 在php中,您的for循環可迭代每個輸入。 使用輸入字段ID作為表單中的名稱。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.