{"id":4647,"date":"2025-04-23T09:35:52","date_gmt":"2025-04-23T08:35:52","guid":{"rendered":"https:\/\/ibex.tech\/wordpress-sites\/?p=4647"},"modified":"2025-04-23T09:35:53","modified_gmt":"2025-04-23T08:35:53","slug":"form-field-default-values","status":"publish","type":"post","link":"https:\/\/ibex.tech\/wordpress-sites\/page-builders\/elementor\/forms\/form-field-default-values","title":{"rendered":"Form field default values"},"content":{"rendered":"\n<p>Currently (2025-04) this seems impossible \/ Elementor can&#8217;t provide a working solution! I&#8217;ve had to give up, hopefully this will get resolved for others&#8230;<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">&#8216;elementor_pro\/forms\/render\/item&#8217; method<\/h4>\n\n\n\n<p><strong><em>In our tests will let you change some things and apparently can be used for checkboxes and select boxes, but providing a text input box value not working for us<\/em><\/strong><\/p>\n\n\n\n<p>There are also hooks for, &#8216;elementor_pro\/forms\/render\/item\/text\/&#8217;, &#8216;elementor_pro\/forms\/render\/item.\/checkbox&#8217;, etc if you prefer a hook that targets only one field type (or you can just check the field type in this)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter('elementor_pro\/forms\/render\/item', function( $item, $index, $form )\n{\n  $form_name = $form->get_settings_for_display( 'form_name' );\n\n  if ($form_name === 'search_page_enter_postcode')\n  {\n  if ($item&#91;'custom_id'] === 'finder_search_near_postcode' )\n    {\n      $item&#91;'field_label'] = 'My new label'; \/\/&lt;&lt;&lt;This works - label text is changed\n      $item&#91;'field_value'] = 'abcdef'; \/\/&lt;&lt;&lt;This doesn't work, field remains blank\n    }\n  }\nreturn($item);\n}, 10, 3<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">&#8216;elementor_pro\/forms\/render&#8217;<\/h4>\n\n\n\n<p><strong><em>Also doesn&#8217;t work in our tests<\/em><\/strong><\/p>\n\n\n\n<p>Elementor support gave us this exampel as the recomended way to do it, but in out tests the hook is never called. If you search &#8216;elementor_pro\/forms\/render&#8217; it also doesn&#8217;t appear in any elementor docs to be able to look it up.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter( 'elementor_pro\/forms\/render', function( $form )\n{\n  $form_name = $form->get_settings( 'form_name' );\n\n  if ( $form_name === 'search_page_enter_postcode' )\n  {\n    foreach ( $form->get_fields() as $index => $field )\n    {\n      if ( isset( $field&#91;'custom_id'] ) &amp;&amp; $field&#91;'custom_id'] === 'finder_search_near_postcode' )\n      {\n        $form->update_field( $index, &#91;\n        'field_value' => 'abcdef'\n        ] );\n      }\n    }\n  }\n\n  return $form;\n  } );<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Currently (2025-04) this seems impossible \/ Elementor can&#8217;t provide a working solution! I&#8217;ve had to give up, hopefully this will get resolved for others&#8230; &#8216;elementor_pro\/forms\/render\/item&#8217; method In our tests will let you change some things and apparently can be used for checkboxes and select boxes, but providing a text input box value not working for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[382],"tags":[],"class_list":["post-4647","post","type-post","status-publish","format-standard","hentry","category-forms"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/comments?post=4647"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4647\/revisions"}],"predecessor-version":[{"id":4648,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4647\/revisions\/4648"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/media?parent=4647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/categories?post=4647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/tags?post=4647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}