Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Custom form built by the admin and then displayed to be filled by users - How to do that ?

Hello,

I will perhaps have to work on an app which needs for the admins to create projects with different steps. Each step has to be customizable with different fields : input, text, select, checkbox, radio, upload, validation by some referent user, generation of custom PDF docs from the data, ...

I never did that, I only began to think about.

  • Has someone already done something like that ?
  • Is there any Laravel (or not Laravel) package which help doing that ?
  • Is it a good idea to have a steps table with a JSON column to save the custom fields ? and then another table to save the data when users fill and save the form ?
  • Other ideas ?

While waiting for some help, I want to test the JSON idea. I'll tell you if it works for me or not.

Thanks for your help.

Vincent

0 likes
5 replies
vincent15000's avatar

@shaungbhone This tool seems to be great but I wonder if it's not only an admin panel and offers the possibility to create some CMS like app. I don't think that's useful for my problem. But I will read the doc and test it to be sure. In fact the admin who have to do this are clients, it's not the superadmin of the application.

vincent15000's avatar

Another idea is to save all the fields of the form in a separate table.

id
order
label
field_type
required
form_id

Is there a best pratice to do all this ? JSON ? separate table ? something else ?

martinbean's avatar
Level 80

@vincent15000 Shoving stuff in JSON in never “best practice” when using a relational database. If you’re using a relational database like MySQL or PostgreSQL, then store data relationally, i.e. in dedicated tables linked with foreign keys.

If you want custom forms then you need to identify the entities in that. At its simplest, you’re going to have a forms table, and then your Form model is going to have a has-many relation pointing to a FormField model or something.

1 like
vincent15000's avatar

@martinbean thank you ... effectively it seems to be the simplest way to that.

I never did that, but I think that in the fields table I will add some specific properties I need to manage the different fiels, like for example : required, label, min, max, selected_id, ... but I don't know if it's a good idea to create a column for each property in the table.

Is it here again a bad idea to use a JSON column to save the properties ?

{
	"validation": {
		"required": "true",
		"min": "4",
		"max": "12"
	}
}

Or one column per property is better ? With this solution, only the needed columns would have datas, the other remaining null.

id
order
label
field_type
required
min
max
size
selected_id
form_id

Please or to participate in this conversation.