ninja_forms_edit_field_calc

Function used to output calcluation options on each field editing section on the back-end.

Description

ninja_forms_edit_field_calc( $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_calc' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/admin/edit-field/calc.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_calc($field_id, $field_data); 
  12.  

Defined (1)

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

/deprecated/includes/admin/edit-field/calc.php  
  1. function ninja_forms_edit_field_calc( $field_id, $field_data ) { 
  2. global $ninja_forms_fields; 
  3.  
  4. $field_row = ninja_forms_get_field_by_id( $field_id ); 
  5. $field_type = $field_row['type']; 
  6. if ( $ninja_forms_fields[$field_type]['process_field'] ) { 
  7. if ( isset ( $field_data['calc_option'] ) ) { 
  8. $calc_option = $field_data['calc_option']; 
  9. } else { 
  10. $calc_option = 0; 
  11.  
  12. if ( isset ( $field_data['calc_auto_include'] ) ) { 
  13. $calc_auto_include = $field_data['calc_auto_include']; 
  14. } else { 
  15. $calc_auto_include = 0; 
  16.  
  17. if ( isset ( $field_data['calc_value'] ) ) { 
  18. $calc_value = $field_data['calc_value']; 
  19. } else { 
  20. $calc_value = 0; 
  21.  
  22. ?> 
  23. <div class="description description-wide"> 
  24. <?php 
  25. if ( $field_type == '_checkbox' ) { 
  26. if ( !isset ( $calc_value['unchecked'] ) ) { 
  27. $calc_value = array(); 
  28. $calc_value['unchecked'] = 0; 
  29. $calc_value['checked'] = 0; 
  30. ninja_forms_edit_field_el_output($field_id, 'text', sprintf( __( '%sChecked%s Calculation Value', 'ninja-forms' ), '<strong>', '</strong>' ), 'calc_value[checked]', $calc_value['checked'], 'wide', '', '', sprintf( __( 'This is the value that will be used if %sChecked%s.', 'ninja-forms' ), '<strong>', '</strong>' ) ); 
  31. ninja_forms_edit_field_el_output($field_id, 'text', sprintf( __( '%sUnchecked%s Calculation Value', 'ninja-forms' ), '<strong>', '</strong>' ), 'calc_value[unchecked]', $calc_value['unchecked'], 'wide', '', '', sprintf( __( 'This is the value that will be used if %sUnchecked%s.', 'ninja-forms' ), '<strong>', '</strong>' ) ); 
  32.  
  33. ninja_forms_edit_field_el_output($field_id, 'checkbox', __( 'Include in the auto-total? (If enabled)', 'ninja-forms' ), 'calc_auto_include', $calc_auto_include, 'wide', '', 'ninja-forms-field-auto-total-include'); 
  34. ?> 
  35. </div> 
  36. <?php