ninja_forms_field_calc_display

Function that outputs the display for our calculation field.

Description

ninja_forms_field_calc_display( $field_id, $data, (string) $form_id = '' ); 

Parameters (3)

0. $field_id
The field id.
1. $data
The data.
2. $form_id — Optional. (string) => ''
The form id.

Usage

  1. if ( !function_exists( 'ninja_forms_field_calc_display' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/fields/calc.php'; 
  3.  
  4. // The field id. 
  5. $field_id = null; 
  6.  
  7. // The data. 
  8. $data = null; 
  9.  
  10. // The form id. 
  11. $form_id = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = ninja_forms_field_calc_display($field_id, $data, $form_id); 
  15.  

Defined (1)

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

/deprecated/includes/fields/calc.php  
  1. function ninja_forms_field_calc_display( $field_id, $data, $form_id = '' ) { 
  2.  
  3. if ( isset( $data['default_value'] ) ) { 
  4. $default_value = $data['default_value']; 
  5. } else { 
  6. $default_value = 0; 
  7.  
  8. if ( $default_value == '' ) { 
  9. $default_value = 0; 
  10.  
  11. if ( isset ( $data['calc_display_text_disabled'] ) AND $data['calc_display_text_disabled'] == 1 ) { 
  12. $disabled = "disabled"; 
  13. } else { 
  14. $disabled = ''; 
  15.  
  16. if ( isset ( $data['calc_display_type'] ) ) { 
  17. $calc_display_type = $data['calc_display_type']; 
  18. } else { 
  19. $calc_display_type = 'text'; 
  20.  
  21. if ( isset ( $data['calc_display_html'] ) ) { 
  22. $calc_display_html = $data['calc_display_html']; 
  23. } else { 
  24. $calc_display_html = ''; 
  25.  
  26. if ( isset ( $data['calc_method'] ) ) { 
  27. $calc_method = $data['calc_method']; 
  28. } else { 
  29. $calc_method = ''; 
  30.  
  31. $field_class = ninja_forms_get_field_class( $field_id, $form_id ); 
  32.  
  33. ?> 
  34. <input type="hidden" name="ninja_forms_field_<?php echo $field_id;?>" value="<?php echo $default_value;?>" class="<?php echo $field_class;?>"> 
  35. <?php 
  36.  
  37. switch ( $calc_display_type ) { 
  38. case 'text': 
  39. ?> 
  40. <input type="text" id="ninja_forms_field_<?php echo $field_id;?>" name="ninja_forms_field_<?php echo $field_id;?>" value="<?php echo $default_value;?>" <?php echo $disabled;?> class="<?php echo $field_class;?>" rel="<?php echo $field_id;?>"> 
  41. <?php 
  42. break; 
  43. case 'html': 
  44. $calc_display_html = str_replace( '[ninja_forms_calc]', '<span id="ninja_forms_field_'.$field_id.'" class="'.$field_class.'" rel="'.$field_id.'">'.$default_value.'</span>', $calc_display_html ); 
  45. echo $calc_display_html; 
  46. break;