Docs & Support

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

frm_field_input_html

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 can be used to add HTML within input tags in a field. It is especially helpful for adding HTML5 placeholder text, required attributes, and formatting field input.

Usage

add_action('frm_field_input_html', 'add_input_html');
function add_input_html($field)

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

Parameters

  • $field (array)

Examples

Insert required and placeholder

Use this code to add HTML directly in your input field. This example adds HTML5 placeholder text and required attributes. This can also be done in your customizable HTML by changing [input] to [input required="required"] or [input placeholder="2"]. Any other HTML can be added in this code or to your customizable HTML as well.

add_action('frm_field_input_html', 'add_input_html');
function add_input_html($field, $echo=true){
  $html = '';
  if($field['id'] == 25){ //change 25 to the ID of your field
     $html = ' required="required"';
  }
  if($field['type'] == 'number'){
     $html = ' placeholder="2"';
  }
  if($echo)
    echo $html;
  return $html;
}

Add the field name as input title

If you would like your input fields to show the field title on hover, you can add it in your customizable HTML with [input title="The field name"]. If you would like this to be on a larger number of fields, php may be easier.

add_action('frm_field_input_html', 'add_input_title');
function add_input_title( $field, $echo = true ) {
  $html = '';
  if($field['type'] == 'text'){
     $html = ' title="'. esc_attr( $field['name'] ) .'"';
  }

  if($echo){
    echo $html;
  }

  return $html;
}

Disable file URLs for uploaded file

Use this code example to disable file URLs for an uploaded file even when file protection is turned off.

add_action( 'frm_field_input_html', 'disable_dropzone_urls' );
function disable_dropzone_urls( $field ) {
	$field_id = 4626; // change 4626 to your field ID
	if ( $field_id !== (int) $field['id'] ) {
		return;
	}

	global $frm_vars;

	$key = 'file' . $field_id;
	if ( ! array_key_exists( $key, $frm_vars['dropzone_loaded'] ) ) {
		return;
	}

	array_walk(
		$frm_vars['dropzone_loaded'][ $key ]['mockFiles'],
		function( &$mock_file ) {
			$mock_file['accessible'] = false;
		}
	);
}
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.

    Complete your purchase
    Special offer unlocked.
    Get 55% OFF!
    Complete Purchase
    Join 400,000+ using Formidable Forms to create form-focused solutions fast. Get Formidable Forms