我正在为我的应用程序建立一个自定义字段功能。 这使管理员能够添加用户根据网站需要填写的自定义配置字段 。
计划很简单
field_meta (store some metadata about the field)
================================================
id
type //type of field
field_name //name of the field in the fields table
render_data //Some data to use when rendering the form field
field
===================
id
name //Default field that can t be deleted
address //Default field that can t be deleted
customfield_1
customfield_2
field_meta
表格用于存储字段的某些元数据,以便我们可以转换窗体字段。
然后将每个字段储存在 field
表格中的新列中。
Problem: For usability and to not have to deal with users choosing reserved words or using non-english words for the column name, I will not be asking users to choose a name for the column name.
目前,我正在考虑按字段类型(应用程序中有相当几种类型(电子邮件、网站、文本、段落等)命名列名,仅举几个例子)并添加一些数字。
- Email_1
- Text_1
- Text_2
- Text_3
- Email_2
- etc
然而,这个方法的问题在于,要得出列名需要相当多的工作。 我需要把所有的列名都取出来, 选出与我所创建的列型相同的列, 以最大数量分析, 然后创建列 。
是否有更好的战略可以做到这一点? 或者用完全不同的方式命名消除这些问题的栏目?