nf_field_calc_advanced_settings

The Ninja Forms nf field calc advanced settings function.

Description

nf_field_calc_advanced_settings( $field_id, $data ); 

Parameters (2)

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

Usage

  1. if ( !function_exists( 'nf_field_calc_advanced_settings' ) ) { 
  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. // NOTICE! Understand what this does before running. 
  11. $result = nf_field_calc_advanced_settings($field_id, $data); 
  12.  

Defined (1)

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

/deprecated/includes/fields/calc.php  
  1. function nf_field_calc_advanced_settings( $field_id, $data ) { 
  2. $field = ninja_forms_get_field_by_id( $field_id ); 
  3. if ( '_calc' != $field['type'] ) 
  4. return false; 
  5.  
  6. $calc_name = isset ( $data['calc_name'] ) ? $data['calc_name'] : 'calc_name'; 
  7. $default_value = isset ( $data['default_value'] ) ? $data['default_value'] : '';  
  8. $calc_payment = isset ( $data['calc_payment'] ) ? $data['calc_payment'] : ''; 
  9. $calc_autho = isset ( $data['calc_auto'] ) ? $data['calc_auto'] : 0; 
  10. $calc_display_type = isset ( $data['calc_display_type'] ) ? $data['calc_display_type'] : 'text'; 
  11.  
  12. ninja_forms_edit_field_el_output($field_id, 'text', __( 'Calculation name', 'ninja-forms' ), 'calc_name', $calc_name, 'wide', '', 'widefat ninja-forms-calc-name', __( 'This is the programmatic name of your field. Examples are: my_calc, price_total, user-total.', 'ninja-forms' )); 
  13. ninja_forms_edit_field_el_output($field_id, 'text', __( 'Default Value', 'ninja-forms' ), 'default_value', $default_value, 'wide', '', 'widefat' ); 
  14.  
  15.  
  16. // If any option besides "none" is selected, then show our custom class and help options. 
  17. if ( $calc_display_type == 'hidden' ) { 
  18. $class = 'hidden'; 
  19. } else { 
  20. $class = ''; 
  21.  
  22. if ( isset ( $data['class'] ) ) { 
  23. $custom_class = $data['class']; 
  24. } else { 
  25. $custom_class = ''; 
  26.  
  27. if ( isset ( $data['show_help'] ) ) { 
  28. $show_help = $data['show_help']; 
  29. } else { 
  30. $show_help = 0; 
  31.  
  32. if ( isset ( $data['help_text'] ) ) { 
  33. $help_text = $data['help_text']; 
  34. } else { 
  35. $help_text = ''; 
  36.  
  37. if( $show_help == 1 ) { 
  38. $display_span = ''; 
  39. } else { 
  40. $display_span = 'display:none;'; 
  41.  
  42. echo '<div id="ninja_forms_field_'.$field_id.'_calc_extra_display" class="'.$class.'">'; 
  43. // Output our custom class textbox. 
  44. ninja_forms_edit_field_el_output($field_id, 'text', __( 'Custom CSS Class', 'ninja-forms' ), 'class', $custom_class, 'wide', '', 'widefat'); 
  45.  
  46. // Output our help text options. 
  47. $help_desc = sprintf(__('If "help text" is enabled, there will be a question mark %s placed next to the input field. Hovering over this question mark will show the help text.', 'ninja-forms'), '<img src="'.NINJA_FORMS_URL.'images/question-ico.gif">'); 
  48. ninja_forms_edit_field_el_output($field_id, 'checkbox', __( 'Show Help Text', 'ninja-forms' ), 'show_help', $show_help, 'wide', '', 'ninja-forms-show-help'); 
  49. ?> 
  50. <span id="ninja_forms_field_<?php echo $field_id;?>_help_span" style="<?php echo $display_span;?>"> 
  51. <?php 
  52. ninja_forms_edit_field_el_output($field_id, 'textarea', __( 'Help Text', 'ninja-forms' ), 'help_text', $help_text, 'wide', '', 'widefat', $help_desc); 
  53. ?> 
  54. </span> 
  55. <?php 
  56. echo '</div>';