Answers.Body: <p>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 <em>context of a field layout</em>.</p>
  
  <p>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.</p>
  
  <p>In order to set a field (in a field layout) as required, first you'll need to know the <em>field's ID</em>. This is easily found by looking at the <code>craft_fields</code> table.</p>
  
  <p>Next, you'll need to know the ID for the <em>field layout</em> 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 <code>fieldLayoutId</code> column in the <code>craft_sproutforms_forms</code> table. <em>For entries, you have to look at the <code>craft_entrytypes</code> table, for categories, you'll have to look at the <code>craft_categorygroups</code> table, etc)</em>.</p>
  
  <p>Finally, you'll need to identify the field in the <code>craft_fieldlayoutfields</code> table, by looking at the <code>layoutId</code> and the <code>fieldId</code> columns. Set the <code>required</code> column for the appropriate row to <code>1</code>, and you're done.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-02T07:45:10.863Z
Answers.Text: 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.
Answers.UserDisplayName: Gareth
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-29T12:38:51.407Z
Answers.LastActivityDate: 2015-12-29T12:38:51.407Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>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.</p>
  
Tags: <field><plugin-sproutforms><required>
Title: Where can you set a form field to required in the DB
ThreadText: # Where can you set a form field to required in the DB
  
  (Asked by: username_0 on 2015-12-29)
  
  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.
  
  **Tags:** field, plugin-sproutforms, required
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-12-29. Score: 3 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_0**: Hi username_1, 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.  
  
  ---
  
  