ninja_forms_display_fields

The Ninja Forms ninja forms display fields function.

Description

ninja_forms_display_fields( $form_id ); 

Parameters (1)

0. $form_id
The form id.

Usage

  1. if ( !function_exists( 'ninja_forms_display_fields' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/display/fields/display-fields.php'; 
  3.  
  4. // The form id. 
  5. $form_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = ninja_forms_display_fields($form_id); 
  9.  

Defined (1)

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

/deprecated/includes/display/fields/display-fields.php  
  1. function ninja_forms_display_fields($form_id) { 
  2. global $ninja_forms_fields, $ninja_forms_loading, $ninja_forms_processing; 
  3.  
  4. $field_results = ninja_forms_get_fields_by_form_id($form_id); 
  5. $field_results = apply_filters('ninja_forms_display_fields_array', $field_results, $form_id); 
  6.  
  7. if ( is_array ( $field_results ) AND !empty ( $field_results ) ) { 
  8. foreach ( $field_results as $field ) { 
  9. if ( isset ( $ninja_forms_loading ) && $ninja_forms_loading->get_form_ID() == $form_id ) { 
  10. $field = $ninja_forms_loading->get_field_settings( $field['id'] ); 
  11. } else if ( isset ( $ninja_forms_processing ) && $ninja_forms_processing->get_form_ID() == $form_id ) { 
  12. $field = $ninja_forms_processing->get_field_settings( $field['id'] ); 
  13.  
  14. if( isset( $ninja_forms_fields[$field['type']] ) ) { 
  15. $type = $ninja_forms_fields[$field['type']]; 
  16.  
  17. $field_id = $field['id']; 
  18. if(isset($field['data']['req'])) { 
  19. $req = $field['data']['req']; 
  20. }else{ 
  21. $req = ''; 
  22.  
  23. $default_label_pos = $type['default_label_pos']; 
  24. $display_wrap = $type['display_wrap']; 
  25. $display_label = $type['display_label']; 
  26. $sub_edit_function = $type['sub_edit_function']; 
  27. $display_function = $type['display_function']; 
  28.  
  29. //Check to see if we are currently editing a form submission. 
  30. //If we are, then $display_function should be set to the sub_edit_function instead. 
  31. if( is_object( $ninja_forms_processing)) { 
  32. $sub_id = $ninja_forms_processing->get_form_setting('sub_id'); 
  33. }else if(isset($_REQUEST['sub_id'])) { 
  34. $sub_id = absint( $_REQUEST['sub_id'] ); 
  35. }else{ 
  36. $sub_id = ''; 
  37.  
  38. if ( $sub_id != '' AND $sub_edit_function != '' AND is_admin() ) { 
  39. $display_function = $sub_edit_function; 
  40.  
  41. $process_field = $type['process_field']; 
  42. $data = $field['data']; 
  43.  
  44.  
  45. //These filters can be used to temporarily modify the settings of a field, i.e. default_value. 
  46. $data = apply_filters( 'ninja_forms_field', $data, $field_id ); 
  47. //Check the show_field value of our $data array. If it is set to false, don't output the field. 
  48. if(isset($data['show_field'])) { 
  49. $show_field = $data['show_field']; 
  50. }else{ 
  51. $show_field = true; 
  52.  
  53. if( isset( $data['display_style'] ) ) { 
  54. $display_style = $data['display_style']; 
  55. }else{ 
  56. $display_style = ''; 
  57.  
  58. if( isset( $data['visible'] ) ) { 
  59. $visible = $data['visible']; 
  60. }else{ 
  61. $visible = true; 
  62.  
  63. if ( $display_style != '' ) { 
  64. $display_style = 'style="'.$display_style.'"'; 
  65.  
  66. if ( $display_function != '' AND $show_field ) { 
  67. if ( isset( $data['label_pos'] ) ) { 
  68. $label_pos = $data['label_pos']; 
  69. }else{ 
  70. $label_pos = ''; 
  71. if( $label_pos == '' ) { 
  72. $label_pos = $default_label_pos; 
  73.  
  74. do_action( 'ninja_forms_display_before_field', $field_id, $data ); 
  75.  
  76. //Check to see if display_wrap has been disabled. If it hasn't, show the wrapping DIV. 
  77. if($display_wrap) { 
  78. $field_wrap_class = ninja_forms_get_field_wrap_class($field_id, $form_id); 
  79. $field_wrap_class = apply_filters( 'ninja_forms_field_wrap_class', $field_wrap_class, $field_id ); 
  80. do_action( 'ninja_forms_display_before_opening_field_wrap', $field_id, $data ); 
  81. ?> 
  82. <div class="<?php echo $field_wrap_class;?>" <?php echo $display_style;?> id="ninja_forms_field_<?php echo $field_id;?>_div_wrap" data-visible="<?php echo $visible;?>"> 
  83. <?php 
  84. do_action( 'ninja_forms_display_after_opening_field_wrap', $field_id, $data ); 
  85.  
  86. //Check to see if display_label has been disabled. If it hasn't, show the label. 
  87. if( $display_label ) { 
  88. if( $label_pos == 'left' OR $label_pos == 'above' ) { // Check the label position variable. If it is left or above, show the label. 
  89. do_action( 'ninja_forms_display_before_field_label', $field_id, $data ); 
  90. do_action( 'ninja_forms_display_field_label', $field_id, $data ); 
  91. do_action( 'ninja_forms_display_after_field_label', $field_id, $data ); 
  92.  
  93. //Check to see if there is a registered display function. If so, call it. 
  94. if($display_function != '') { 
  95.  
  96. do_action( 'ninja_forms_display_before_field_function', $field_id, $data ); 
  97. $arguments['field_id'] = $field_id; 
  98. $arguments['data'] = $data; 
  99. $arguments['form_id'] = $form_id; 
  100. call_user_func_array($display_function, $arguments); 
  101. do_action( 'ninja_forms_display_after_field_function', $field_id, $data ); 
  102. if( $label_pos == 'left' OR $label_pos == 'inside') { 
  103. do_action( 'ninja_forms_display_field_help', $field_id, $data ); 
  104.  
  105. //Check to see if display_label has been disabled. If it hasn't, show the label. 
  106. if($display_label) { 
  107. if($label_pos == 'right' OR $label_pos == 'below') { // Check the label position variable. If it is right or below, show the label. 
  108. do_action( 'ninja_forms_display_before_field_label', $field_id, $data ); 
  109. do_action( 'ninja_forms_display_field_label', $field_id, $data ); 
  110. do_action( 'ninja_forms_display_after_field_label', $field_id, $data ); 
  111.  
  112. //Check to see if display_wrap has been disabled. If it hasn't close the wrapping DIV 
  113. if($display_wrap) { 
  114. do_action( 'ninja_forms_display_before_closing_field_wrap', $field_id, $data ); 
  115. ?> 
  116. </div> 
  117. <?php 
  118. do_action( 'ninja_forms_display_after_closing_field_wrap', $field_id, $data ); 
  119. do_action( 'ninja_forms_display_after_field', $field_id, $data );