Formidable Forms

Formidable Forms

  • Features
  • Pricing
  • Resources
    • Docs & Support
    • Blog
    • Community
  • Solutions
    • Web Applications
    • Calculators
    • Surveys
    • Directories
    • Payments
    • Contact forms
  • Login
  • Get Formidable Forms

frm_get_paged_fields

Last Updated: May 2, 2018

Knowledge Base → Extend Formidable Forms → Formidable Hooks - for Developers → Field Appearance → frm_get_paged_fields
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

If you have a multi-page form, you can use this filter to display the same field multiple times.

Formidable Forms is the best WordPress Form Builder plugin. Get it for free!

Usage

add_filter('frm_get_paged_fields', 'get_extra_form_fields', 10, 3);
function get_extra_form_fields($fields, $form_id, $error=false)

Parameters

  • $fields (array)
  • $form_id (integer)
  • $error (boolean - whether or not there was a validation error on the page )

Examples

Show all fields on the final page of a multi-paged form

This code will get all the specified fields and display them on the last page of the form. These fields will still appear in their normal position as well.

add_filter('frm_get_paged_fields', 'get_extra_form_fields', 30, 3);
function get_extra_form_fields($fields, $form_id, $error=false){
  if($form_id == 25){ //change 25 to the id of the form to change
      $prev_page = FrmAppHelper::get_param('frm_page_order_'. $form_id, false);
      if($prev_page > 3){ //change 3 to a number higher than the order of second to last page break
          $new_fields = FrmField::getAll( 'fi.id in (45,46)', 'field_order' ); //change 45,46 to the IDs of the fields you'd like to show on the last page
          $fields = array_merge($fields, $new_fields); //if you want to mess with the order, you can tinker with this on your own
      }
  }
  return $fields;
}

The $prev_page > 3 is a bit confusing. In my example, I had a page break that was the 5th field in the form, so pick a number smaller than that, but bigger than any previous page breaks.

Remove page breaks from the admin

Use this if you would like your form to all be one a single page when you are creating or editing an entry from the back-end.

Note: This snippet is not intended for use with repeater fields.

add_filter( 'frm_get_paged_fields', 'remove_my_breaks', 9, 2 );
function remove_my_breaks( $fields, $form_id ) {
  if ( ! is_admin() ) {
    return $fields;
  }
  if ( $form_id == 12 ) { // change 12 to the ID of your form
    remove_filter( 'frm_get_paged_fields', 'FrmProFieldsHelper::get_form_fields', 10, 3 );
    foreach( (array) $fields as $k => $f ) {
      if ( $f->type == 'break' ) {
        unset( $fields[ $k ] );
      }
    }
  }
  return $fields;
}

If you want to remove page breaks on the front-end, remove the following from the above example:

if ( ! is_admin() ) {
    return $fields;
}

Randomize Field Order

Each time the form is loaded, the order of the fields on the current page will be randomized. The user experience will be best if ajax submit is turned on to prevent page reload and field reordering.

add_filter( 'frm_get_paged_fields', 'randomize_form_fields', 20, 2 );
function randomize_form_fields( $fields, $form_id ){
	if ( $form_id == 25 ) { //change 25 to the id of the form to change
		shuffle( $fields );
	}
	return $fields; 
}
  • Usage
  • Parameters
  • Examples
    • Show all fields on the final page of a multi-paged form
    • Remove page breaks from the admin
    • Randomize Field Order
Categories
×

Categories

  • Installation & Getting Started
  • Account Management
  • Forms
  • Entries
  • Views
  • Styles
  • Importing & Exporting
  • Add-Ons
  • Extend Formidable Forms

Using WordPress and want to get Formidable Forms for free?

Get Formidable Forms Lite Now

You do not have permission to view this form. Maybe you need to log in?

This article may contain affiliate links. Once in a while, we earn commissions from those links. But we only recommend products we like, with or without commissions.

Take on bigger projects Right Now

Get the tools you need to revolutionize your workflow and architect a masterpiece. Build the most advanced WordPress forms and actually use the data you collect in meaningful ways.

Get the most advanced WordPress form plugin and the only form builder with integrated Views.

Get Formidable Forms Now

Resources

  • Community
  • Affiliates
  • Contact
  • Free Online Form Builder

Top Features

  • Application Builder
  • Calculator Forms
  • Surveys & Polls
  • Quiz Maker
  • Form Templates
  • Application Templates
  • Directories
  • Donation Plugin

Company

  • About Us
  • Giving Back
  • Careers
  • Newsletter
  • WP Tasty
  • Nutrifox

Copyright © 2023 Strategy11, LLC. Formidable FormsĀ® is a registered trademark Strategy11, LLC.
Privacy Policy | Terms of Service | Sitemap

Join 300,000+ using Formidable Forms to create form-focused solutions fast. Get Started See User Reviews