ninja_forms_edit_field_input_limit

Function that adds a character and word limit option to textboxes and textareas.

Description

ninja_forms_edit_field_input_limit( $field_id, $field_data ); 

Parameters (2)

0. $field_id
The field id.
1. $field_data
The field data.

Usage

  1. if ( !function_exists( 'ninja_forms_edit_field_input_limit' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/admin/edit-field/input-limit.php'; 
  3.  
  4. // The field id. 
  5. $field_id = null; 
  6.  
  7. // The field data. 
  8. $field_data = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = ninja_forms_edit_field_input_limit($field_id, $field_data); 
  12.  

Defined (1)

The function is defined in the following location(s).

/deprecated/includes/admin/edit-field/input-limit.php  
  1. function ninja_forms_edit_field_input_limit( $field_id, $field_data ) { 
  2.  
  3. $field_row = ninja_forms_get_field_by_id($field_id); 
  4. $field_type = $field_row['type']; 
  5.  
  6. $allowed_types = apply_filters( 'nf_input_limit_types', array( '_text', '_textarea' ) ); 
  7.  
  8. if ( ! in_array( $field_type, $allowed_types ) ) 
  9. return false; 
  10.  
  11. if ( isset ( $field_data['input_limit'] ) ) { 
  12. $input_limit = $field_data['input_limit']; 
  13. } else { 
  14. $input_limit = ''; 
  15.  
  16. if ( isset ( $field_data['input_limit_type'] ) ) { 
  17. $input_limit_type = $field_data['input_limit_type']; 
  18. } else { 
  19. $input_limit_type = ''; 
  20.  
  21. if ( isset ( $field_data['input_limit_msg'] ) ) { 
  22. $input_limit_msg = $field_data['input_limit_msg']; 
  23. } else { 
  24. $input_limit_msg = ''; 
  25.  
  26. $desc = '<em>'.__( 'If you leave the box empty, no limit will be used', 'ninja-forms' ).'</em>'; 
  27. ninja_forms_edit_field_el_output( $field_id, 'text', __( 'Limit input to this number', 'ninja-forms' ), 'input_limit', $input_limit, 'thin', '', 'widefat', $desc ); 
  28. ninja_forms_edit_field_el_output( $field_id, 'select', __( 'of', 'ninja-forms' ), 'input_limit_type', $input_limit_type, 'thin', array( array( 'name' => __( 'Characters', 'ninja-forms' ), 'value' => 'char') , array( 'name' => __( 'Words', 'ninja-forms' ), 'value' => 'word' ) ), 'widefat' ); 
  29. echo '<p class="description description-wide"> </p>'; 
  30. ninja_forms_edit_field_el_output( $field_id, 'text', __( 'Text to appear after character/word counter', 'ninja-forms' ), 'input_limit_msg', $input_limit_msg, 'wide', '', 'widefat' );