nf_get_field_admin_label

Takes a field ID and returns the admin label if it exists and the label if it does not.

Description

(string) nf_get_field_admin_label( (int) $field_id, (string) $form_id = '' ); 

Returns (string)

$label

Parameters (2)

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

Usage

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

Defined (1)

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

/deprecated/includes/functions.php  
  1. function nf_get_field_admin_label( $field_id, $form_id = '' ) { 
  2.  
  3. if ( empty ( $form_id ) ) { 
  4. $form = ninja_forms_get_form_by_field_id( $field_id ); 
  5. $form_id = $form['id']; 
  6.  
  7. $admin_label = isset( Ninja_Forms()->form( $form_id )->fields[ $field_id ]['data']['admin_label'] ) ? Ninja_Forms()->form( $form_id )->fields[ $field_id ]['data']['admin_label'] : ''; 
  8. $field_label = isset( Ninja_Forms()->form( $form_id )->fields[ $field_id ]['data']['label'] ) ? Ninja_Forms()->form( $form_id )->fields[ $field_id ]['data']['label'] : ''; 
  9.  
  10. if ( ! empty( $admin_label ) ) { 
  11. $label = $admin_label; 
  12. } else { 
  13. $label = $field_label; 
  14.  
  15. return $label;