ninja_forms_display_field_label

Outputs the HTML of the field label if it is set to display.

Description

ninja_forms_display_field_label( $field_id, $data ); 

Also outputs the required symbol if it is set.

Parameters (2)

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

Usage

  1. if ( !function_exists( 'ninja_forms_display_field_label' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/display/fields/label.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 = ninja_forms_display_field_label($field_id, $data); 
  12.  

Defined (1)

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

/deprecated/includes/display/fields/label.php  
  1. function ninja_forms_display_field_label( $field_id, $data ) { 
  2. global $ninja_forms_fields, $ninja_forms_loading, $ninja_forms_processing; 
  3.  
  4. $field = ninja_forms_get_field_by_id( $field_id ); 
  5. $form_id = $field['form_id']; 
  6.  
  7. $plugin_settings = nf_get_settings(); 
  8.  
  9. if ( isset ( $ninja_forms_loading ) && $ninja_forms_loading->get_form_ID() == $form_id ) { 
  10. $field_row = $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_row = $ninja_forms_processing->get_field_settings( $field_id ); 
  13.  
  14. $field_type = $field_row['type']; 
  15.  
  16. if( isset ( $data['label'] ) ) { 
  17. $label = stripslashes($data['label']); 
  18. } else if ( isset ( $ninja_forms_fields[$field_type]['default_label'] ) ) { 
  19. $label = $ninja_forms_fields[$field_type]['default_label']; 
  20. } else { 
  21. $label = ''; 
  22.  
  23. if( isset ( $data['label_pos'] ) ) { 
  24. $label_pos = stripslashes($data['label_pos']); 
  25. } else { 
  26. $label_pos = ''; 
  27.  
  28. if ( isset( $plugin_settings['req_field_symbol'] ) ) { 
  29. $req_symbol = $plugin_settings['req_field_symbol']; 
  30. } else { 
  31. $req_symbol = ''; 
  32.  
  33. if ( isset ( $data['req'] ) ) { 
  34. $req = $data['req']; 
  35. } else { 
  36. $req = ''; 
  37.  
  38. if ( isset ( $data['display_label'] ) ) { 
  39. $display_label = $data['display_label']; 
  40. } else { 
  41. $display_label = true; 
  42.  
  43. $label_class = ''; 
  44.  
  45. $label_class = apply_filters( 'ninja_forms_label_class', $label_class, $field_id ); 
  46.  
  47. if ( $display_label ) { 
  48. if ( $req == 1 && $req_symbol != '' && $label_pos != 'inside' ) { 
  49. $req_span = "<span class='ninja-forms-req-symbol'>$req_symbol</span>"; 
  50. } else { 
  51. $req_span = ''; 
  52. ?> 
  53. <label for="ninja_forms_field_<?php echo $field_id;?>" id="ninja_forms_field_<?php echo $field_id;?>_label" class="<?php echo $label_class;?>"><?php echo $label;?> <?php echo $req_span;?> 
  54. <?php 
  55. if ( $label_pos != 'left' ) { 
  56. do_action( 'ninja_forms_display_field_help', $field_id, $data ); 
  57. ?> 
  58. </label> 
  59. <?php