Can someone point me to where in the DB you set a field as required? I am actually wanting to do this on a Sprout Forms field I am not sure if that makes a difference or not. I can't find which table you would do that in.


In Craft, fields can be shared across field layouts and there's no way to set a field as required across the board. A field can only be declared as "required" in the context of a field layout.

Usually this is easily done by clicking the cogwheel next to a field inside a tab in the field layout designer, and selecting "Make required". Sprout Forms uses the standard field layout designer, so you'll have this option here as well – though I'm guessing you have a specific reason for wanting to do it in the database.

In order to set a field (in a field layout) as required, first you'll need to know the field's ID. This is easily found by looking at the craft_fields table.

Next, you'll need to know the ID for the field layout you want to modify. In this case, you want the layout used by a specific Sprout Form, so the easiest way is to look at the fieldLayoutId column in the craft_sproutforms_forms table. For entries, you have to look at the craft_entrytypes table, for categories, you'll have to look at the craft_categorygroups table, etc).

Finally, you'll need to identify the field in the craft_fieldlayoutfields table, by looking at the layoutId and the fieldId columns. Set the required column for the appropriate row to 1, and you're done.

  • Hi Mats, thank you for your detailed response. The only reason I am needing to do this is because there seems to be a JS bug that prevents me from setting the field to required. So this is just a temp fix so that I can carry on testing until the main bug is fixed. – Gareth Jan 2 '16 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.