<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Set all fields required via functions.php</title>
		<link>https://legacy.forums.gravityhelp.com/topic/set-all-fields-required-via-functionsphp</link>
		<description>Gravity Support Forums Topic: Set all fields required via functions.php</description>
		<language>en-US</language>
		<pubDate>Mon, 20 Apr 2026 15:23:06 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/set-all-fields-required-via-functionsphp" rel="self" type="application/rss+xml" />

		<item>
			<title>netsal.es on "Set all fields required via functions.php"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/set-all-fields-required-via-functionsphp#post-58303</link>
			<pubDate>Wed, 09 May 2012 08:30:45 +0000</pubDate>
			<dc:creator>netsal.es</dc:creator>
			<guid isPermaLink="false">58303@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks for the reply Rob,&#60;/p&#62;
&#60;p&#62;thats a &#34;good to know&#34; for the future! Thanks!&#60;/p&#62;
&#60;p&#62;So any advise how I could turn all my fields to required now in the backend without having to click each field? I started to build the form with fields not set to required.&#60;br /&#62;
Please do not tell me my only choice is now to go through all the fields! (100+) :(
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Rob Harrell on "Set all fields required via functions.php"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/set-all-fields-required-via-functionsphp#post-58292</link>
			<pubDate>Wed, 09 May 2012 08:00:28 +0000</pubDate>
			<dc:creator>Rob Harrell</dc:creator>
			<guid isPermaLink="false">58292@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Rather than messing around with that, check out this cool tutorial for faster multi-page form testing:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://gravitywiz.com/2012/05/04/pro-tip-skip-pages-on-multi-page-forms/&#34; rel=&#34;nofollow&#34;&#62;http://gravitywiz.com/2012/05/04/pro-tip-skip-pages-on-multi-page-forms/&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>netsal.es on "Set all fields required via functions.php"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/set-all-fields-required-via-functionsphp#post-58280</link>
			<pubDate>Wed, 09 May 2012 07:40:41 +0000</pubDate>
			<dc:creator>netsal.es</dc:creator>
			<guid isPermaLink="false">58280@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Follow up:&#60;/p&#62;
&#60;p&#62;I managed to leave out the html fields, but i can not proceed to the next page in my form...&#60;br /&#62;
(I updated the code above accordingly)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>netsal.es on "Set all fields required via functions.php"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/set-all-fields-required-via-functionsphp#post-58279</link>
			<pubDate>Wed, 09 May 2012 07:20:32 +0000</pubDate>
			<dc:creator>netsal.es</dc:creator>
			<guid isPermaLink="false">58279@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I am working on a form with 100+ fields, which is seperated in multiple pages.&#60;br /&#62;
In order to be able to test the form more fast i set NO field required.&#60;/p&#62;
&#60;p&#62;If i want to set all fields required before release, I want to be able to do that via the functions.php.&#60;/p&#62;
&#60;p&#62;Here is an Example, based on &#60;a href=&#34;http://www.gravityhelp.com/forums/topic/ensure-required-box-is-ticked-by-default#post-35416&#34; rel=&#34;nofollow&#34;&#62;this&#60;/a&#62;&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_pre_render&#38;quot;, &#38;quot;set_required&#38;quot;);
add_filter(&#38;quot;gform_validation&#38;quot;, &#38;quot;check_required&#38;quot;);

function set_required($form){
    foreach($form[&#38;quot;fields&#38;quot;] as &#38;amp;$field){
     if ($field[&#38;quot;type&#38;quot;] != &#38;quot;html&#38;quot;)
    {
        $field[&#38;quot;isRequired&#38;quot;] = true;}
}
    return $form;
}

function check_required($validation_result){
    foreach($validation_result[&#38;quot;form&#38;quot;][&#38;quot;fields&#38;quot;] as &#38;amp;$field){
     if ($field[&#38;quot;type&#38;quot;] != &#38;quot;html&#38;quot;)
      {

        if(GFFormDisplay::is_empty($field, $validation_result[&#38;quot;form&#38;quot;][&#38;quot;id&#38;quot;])){
            $field[&#38;quot;failed_validation&#38;quot;] = true;
            $field[&#38;quot;validation_message&#38;quot;] = &#38;quot;This field is required.&#38;quot;;
            $validation_result[&#38;quot;is_valid&#38;quot;] = false;
        }
      }
    }
    return $validation_result;}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;The problem: it also sets my html fields to required, even that is not supposed to happen?&#60;br /&#62;
See &#60;a href=&#34;http://www.gravityhelp.com/documentation/page/Field_Object&#34; rel=&#34;nofollow&#34;&#62;isRequired&#60;/a&#62;
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
