ninja_forms_field_list_edit

The Ninja Forms ninja forms field list edit function.

Description

ninja_forms_field_list_edit( $field_id, $data ); 

Parameters (2)

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

Usage

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

Defined (1)

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

/deprecated/includes/fields/list.php  
  1. function ninja_forms_field_list_edit( $field_id, $data ) { 
  2. global $wpdb; 
  3.  
  4. $list_type = isset( $data['list_type'] ) ? $data['list_type'] : ''; 
  5. $hidden = isset( $data['list_show_value'] ) ? $data['list_show_value'] : 0; 
  6. $multi_size = isset( $data['multi_size'] ) ? $data['multi_size'] : 5; 
  7. $default_options = array( 
  8. array( 'label' => 'Option 1', 'value' => '', 'calc' => '', 'selected' => 0 ),  
  9. array( 'label' => 'Option 2', 'value' => '', 'calc' => '', 'selected' => 0 ),  
  10. array( 'label' => 'Option 3', 'value' => '', 'calc' => '', 'selected' => 0 ),  
  11. ); 
  12.  
  13. $list_options = isset ( $data['list']['options'] ) ? $data['list']['options'] : $default_options; 
  14.  
  15. $list_type_options = array( 
  16. array('name' => __( 'Dropdown', 'ninja-forms' ), 'value' => 'dropdown'),  
  17. array('name' => __( 'Radio', 'ninja-forms' ), 'value' => 'radio'),  
  18. array('name' => __( 'Checkboxes', 'ninja-forms' ), 'value' => 'checkbox'),  
  19. array('name' => __( 'Multi-Select', 'ninja-forms' ), 'value' => 'multi'),  
  20. ); 
  21.  
  22. ninja_forms_edit_field_el_output( $field_id, 'select', __( 'List Type', 'ninja-forms' ), 'list_type', $list_type, 'wide', $list_type_options, 'widefat' ); 
  23.  
  24. ?> 
  25.  
  26. <p id="ninja_forms_field_<?php echo $field_id;?>_multi_size_p" class="description description-wide" style="<?php if($list_type != 'multi') { echo 'display:none;';}?>"> 
  27. <?php _e( 'Multi-Select Box Size', 'ninja-forms' );?>: <input type="text" id="" name="ninja_forms_field_<?php echo $field_id;?>[multi_size]" value="<?php echo $multi_size;?>"> 
  28. </p> 
  29. <span id="ninja_forms_field_<?php echo $field_id;?>_list_span" class="ninja-forms-list-span"> 
  30. <!-- <p class="description description-wide"> --> 
  31. <a href="#" id="ninja_forms_field_<?php echo $field_id;?>_list_add_option" class="ninja-forms-field-add-list-option button-secondary"><?php _e( 'Add New', 'ninja-forms' );?></a> 
  32. <a href="#TB_inline?width=640&height=530&inlineId=ninja_forms_field_<?php echo $field_id;?>_import_options_div" class="thickbox button-secondary" title="<?php _e( 'Import List Items', 'ninja-forms' ); ?>" id=""><?php _e( 'Import List Items', 'ninja-forms' );?></a> 
  33. <!-- </p> --> 
  34.  
  35. <p class="description description-wide"> 
  36. <input type="hidden" id="" name="ninja_forms_field_<?php echo $field_id;?>[list_show_value]" value="0"> 
  37. <label for="ninja_forms_field_<?php echo $field_id;?>_list_show_value"><input type="checkbox" value="1" id="ninja_forms_field_<?php echo $field_id;?>_list_show_value" name="ninja_forms_field_<?php echo $field_id;?>[list_show_value]" class="ninja-forms-field-list-show-value" <?php if(isset($data['list_show_value']) AND $data['list_show_value'] == 1) { echo "checked='checked'";}?>> 
  38. <?php _e( 'Show list item values', 'ninja-forms' );?> </label> 
  39. </p> 
  40. <div id="ninja_forms_field_<?php echo $field_id;?>_list_options" class="ninja-forms-field-list-options description description-wide"> 
  41. <input type="hidden" name="ninja_forms_field_<?php echo $field_id;?>[list][options]" value=""> 
  42. <?php 
  43. if( isset( $list_options ) AND is_array( $list_options ) AND $list_options != '' ) { 
  44. $x = 0; 
  45. foreach( $list_options as $option ) { 
  46. ninja_forms_field_list_option_output( $field_id, $x, $option, $hidden ); 
  47. $x++; 
  48. ?> 
  49.  
  50. </div> 
  51. </span> 
  52. <?php add_thickbox(); ?> 
  53. <div id="ninja_forms_field_<?php echo $field_id;?>_import_options_div" style="display:none;"> 
  54. <textarea id="test" class="list-import-textarea"></textarea> 
  55. <input type="button" class="save-list-import button-secondary" value="<?php _e( 'Import', 'ninja-forms' ); ?>" rel="<?php echo $field_id;?>"> 
  56. <input type="button" class="cancel-list-import button-secondary" value="<?php _e( 'Cancel', 'ninja-forms' ); ?>"> 
  57. <p><?php _e( 'To use this feature, you can paste your CSV into the textarea above.', 'ninja-forms' );?></p> 
  58. <p><?php _e( 'The format should look like the following:', 'ninja-forms' );?></p> 
  59. <pre> 
  60. <?php 
  61. $example1 = _x( 'Label, Value, Calc', 'Example for list importing. Leave puncation in place.', 'ninja-forms' ); 
  62. echo $example1; 
  63. echo '<br />'; 
  64. echo $example1; 
  65. echo '<br />'; 
  66. echo $example1; 
  67. ?> 
  68. </pre> 
  69.  
  70. <p><?php _e( "If you want to send an empty value or calc, you should use '' for those.", 'ninja-forms' );?></p> 
  71. <pre> 
  72. <?php 
  73. $example2 = __( 'Label', 'ninja-forms' ) . ", '', ''"; 
  74. echo $example2; 
  75. echo '<br />'; 
  76. echo $example2; 
  77. echo '<br />'; 
  78. echo $example2; 
  79. ?> 
  80. </pre> 
  81.  
  82.  
  83. </div> 
  84. <?php