ninja_forms_field_list_option_output

The Ninja Forms ninja forms field list option output function.

Description

ninja_forms_field_list_option_output( $field_id, $x, (string) $option = '', (string) $hidden = '' ); 

Parameters (4)

0. $field_id
The field id.
1. $x
The x.
2. $option — Optional. (string) => ''
The option.
3. $hidden — Optional. (string) => ''
The hidden.

Usage

  1. if ( !function_exists( 'ninja_forms_field_list_option_output' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/fields/list.php'; 
  3.  
  4. // The field id. 
  5. $field_id = null; 
  6.  
  7. // The x. 
  8. $x = null; 
  9.  
  10. // The option. 
  11. $option = ''; 
  12.  
  13. // The hidden. 
  14. $hidden = ''; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = ninja_forms_field_list_option_output($field_id, $x, $option, $hidden); 
  18.  

Defined (1)

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

/deprecated/includes/fields/list.php  
  1. function ninja_forms_field_list_option_output($field_id, $x, $option = '', $hidden = '') { 
  2. if($hidden == 1) { 
  3. $hidden = ''; 
  4. }else{ 
  5. $hidden = 'display:none'; 
  6. if(is_array($option)) { 
  7. $label = htmlspecialchars( $option['label'] ); 
  8. $label = str_replace( '&', '&', $label ); 
  9. $value = htmlspecialchars( $option['value'] ); 
  10. $value = str_replace( '&', '&', $value ); 
  11. if ( isset ( $option['calc'] ) ) { 
  12. $calc = $option['calc']; 
  13. } else { 
  14. $calc = ''; 
  15. if( isset( $option['selected'] ) ) { 
  16. $selected = $option['selected']; 
  17. }else{ 
  18. $selected = ''; 
  19. $hide = ''; 
  20. }else{ 
  21. $label = ''; 
  22. $value = ''; 
  23. $selected = ''; 
  24. $calc = ''; 
  25. $hide = 'style="display:none;"'; 
  26. if($selected == 1) { 
  27. $selected = "checked='checked'"; 
  28.  
  29. ?> 
  30. <div id="ninja_forms_field_<?php echo $field_id;?>_list_option_<?php echo $x;?>" class="ninja-forms-field-<?php echo $field_id;?>-list-option ninja-forms-field-list-option" <?php echo $hide;?> data-field="<?php echo $field_id; ?>"> 
  31. <table class="list-options"> 
  32. <tr> 
  33. <td class="ninja-forms-delete-list-option-td"> 
  34. <a href="#" id="ninja_forms_field_<?php echo $field_id;?>_list_remove_option" class="nf-remove-list-option"><span class="dashicons dashicons-dismiss"></span></a> 
  35. </td> 
  36. <td class="ninja-forms-list-option-label-td"> 
  37. <?php _e( 'Label', 'ninja-forms' );?>: <input type="text" name="ninja_forms_field_<?php echo $field_id;?>[list][options][<?php echo $x;?>][label]" id="ninja_forms_field_<?php echo $field_id;?>_list_option_label" class="ninja-forms-field-list-option-label" value="<?php echo $label;?>"> 
  38. </td> 
  39. <td class="ninja-forms-list-option-value-td"> 
  40. <span id="ninja_forms_field_<?php echo $field_id;?>_list_option_<?php echo $x;?>_value_span" name="" class="ninja-forms-field-<?php echo $field_id;?>-list-option-value" style="<?php echo $hidden;?>"><?php _e( 'Value', 'ninja-forms' );?>: <input type="text" name="ninja_forms_field_<?php echo $field_id;?>[list][options][<?php echo $x;?>][value]" id="ninja_forms_field_<?php echo $field_id;?>_list_option_value" class="ninja-forms-field-list-option-value" value="<?php echo $value;?>"></span> 
  41. </td> 
  42. <td class="ninja-forms-list-option-calc-td"> 
  43. <?php _ex( 'Calc', 'Short for calculation', 'ninja-forms' );?>: <input type="text" name="ninja_forms_field_<?php echo $field_id;?>[list][options][<?php echo $x;?>][calc]" id="ninja_forms_field_<?php echo $field_id;?>_list_option_calc" class="ninja-forms-field-list-option-calc" value="<?php echo $calc;?>"> 
  44. </td> 
  45. <td class="ninja-forms-list-option-selected-td"> 
  46. <label for="ninja_forms_field_<?php echo $field_id;?>_options_<?php echo $x;?>_selected"><?php _e( 'Selected', 'ninja-forms' );?> <input type="hidden" value="0" name="ninja_forms_field_<?php echo $field_id;?>[list][options][<?php echo $x;?>][selected]"><input type="checkbox" value="1" name="ninja_forms_field_<?php echo $field_id;?>[list][options][<?php echo $x;?>][selected]" id="ninja_forms_field_<?php echo $field_id;?>_options_<?php echo $x;?>_selected" class="ninja-forms-field-list-option-selected" <?php echo $selected;?>></label> 
  47. </td> 
  48. <td class="ninja-forms-list-option-drag-td"> 
  49. <span class="ninja-forms-drag"><span class="dashicons dashicons-menu"></span></span> 
  50. </td> 
  51. </tr> 
  52. </table> 
  53. </div> 
  54.  
  55. <?php