Docs & Support

Learn about all the Formidable features and get support from our amazing customer success team.

frm_form_classes

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.

This hook allows you to add classes to the <form> tag for all forms or only those that are specified. This code can be used to add a background color to your forms.

Usage

add_action('frm_form_classes', 'frm_form_classes');
function frm_form_classes($form)

Formidable Forms makes advanced site building simple. Launch forms, directories, dashboards, and custom WordPress apps faster than ever before.

Parameters

  • $form (object)

Examples

Add a class to a form

add_action( 'frm_form_classes', 'frm_form_classes' );
function frm_form_classes( $form ) {
  if ( $form->id == 25 ) { //Change 25 to the ID of your form
    echo 'new_class';
  }
}

Add a class to all forms

add_action( 'frm_form_classes', 'frm_form_classes' );
function frm_form_classes( $form ) {
  echo 'new_class';
}

Add class to form based on param

You can use this code example to add a class to your form in some locations on your site but not others. This class can be used to add different styling to the form.

Use the add_class param to set the value of the new class. You can add the add_class param to your form shortcode or set it using frm-set-get.

add_action( 'frm_form_classes', 'frm_add_new_class' );
function frm_add_new_class( $form ) {
	if ( ! isset( $_GET['add_class'] ) ) {
		return;
	}

	$new_class = $_GET['add_class'];
	$new_class = utf8_decode( urldecode( $new_class ) );

	echo esc_html( $new_class );
}

Usage:

  • As a param in the form shortcode: Please select a valid form
  • Using frm-set-get: [frm-set-get add_class="rose"]
    [formidable id="1245"] Or add a Formidable forms block to display the form. Note: frm-set-get needs to be before the form on the page.
Was this article helpful? *

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.

In this article

    We have a small, but amazing team of dedicated people who are committed to helping you achieve your goals and project requirements.


    Copyright © 2025 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.

    Join 400,000+ using Formidable Forms to create form-focused solutions fast. Get Formidable Forms