ninja_forms_field_list_display

The Ninja Forms ninja forms field list display function.

Description

ninja_forms_field_list_display( $field_id, $data, (string) $form_id = '' ); 

Parameters (3)

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

Usage

  1. if ( !function_exists( 'ninja_forms_field_list_display' ) ) { 
  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. // The form id. 
  11. $form_id = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = ninja_forms_field_list_display($field_id, $data, $form_id); 
  15.  

Defined (1)

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

/deprecated/includes/fields/list.php  
  1. function ninja_forms_field_list_display( $field_id, $data, $form_id = '' ) { 
  2. global $wpdb, $ninja_forms_fields; 
  3.  
  4. if(isset($data['show_field'])) { 
  5. $show_field = $data['show_field']; 
  6. }else{ 
  7. $show_field = true; 
  8.  
  9. $field_class = ninja_forms_get_field_class( $field_id, $form_id ); 
  10. $field_row = ninja_forms_get_field_by_id($field_id); 
  11.  
  12. $type = $field_row['type']; 
  13. $type_name = $ninja_forms_fields[$type]['name']; 
  14.  
  15. if ( isset( $data['list_type'] ) ) { 
  16. $list_type = $data['list_type']; 
  17. } else { 
  18. $list_type = ''; 
  19.  
  20. if(isset($data['list_show_value'])) { 
  21. $list_show_value = $data['list_show_value']; 
  22. }else{ 
  23. $list_show_value = 0; 
  24.  
  25. if( isset( $data['list']['options'] ) AND $data['list']['options'] != '' ) { 
  26. $options = $data['list']['options']; 
  27. }else{ 
  28. $options = array(); 
  29.  
  30. if(isset($data['label_pos'])) { 
  31. $label_pos = $data['label_pos']; 
  32. }else{ 
  33. $label_pos = 'left'; 
  34.  
  35. if(isset($data['label'])) { 
  36. $label = $data['label']; 
  37. }else{ 
  38. $label = $type_name; 
  39.  
  40. if( isset( $data['multi_size'] ) ) { 
  41. $multi_size = $data['multi_size']; 
  42. }else{ 
  43. $multi_size = 5; 
  44.  
  45. if( isset( $data['default_value'] ) AND !empty( $data['default_value'] ) ) { 
  46. $selected_value = $data['default_value']; 
  47. }else{ 
  48. $selected_value = ''; 
  49.  
  50. $list_options_span_class = apply_filters( 'ninja_forms_display_list_options_span_class', '', $field_id ); 
  51.  
  52. switch($list_type) { 
  53. case 'dropdown': 
  54. echo apply_filters( 'ninja_forms_dropdown_open_tag', '<select name="ninja_forms_field_'.$field_id.'" id="ninja_forms_field_'.$field_id.'" class="'.$field_class.'" rel="'.$field_id.'">', $field_id, $field_class, $data, $ninja_forms_fields, $options ); 
  55. ?> 
  56. <?php 
  57. $select_placeholder = ''; 
  58. if($label_pos == 'inside') { 
  59. $select_placeholder = '<option value="">'.$label.'</option>'; 
  60. echo apply_filters( 'ninja_forms_dropdown_placeholder', $select_placeholder, $label, $label_pos, $field_id, $field_class, $data, $ninja_forms_fields, $options ); 
  61. foreach($options as $option) { 
  62.  
  63. if(isset($option['value'])) { 
  64. $value = $option['value']; 
  65. }else{ 
  66. $value = $option['label']; 
  67.  
  68. $value = htmlspecialchars( $value, ENT_QUOTES ); 
  69.  
  70. if(isset($option['label'])) { 
  71. $label = $option['label']; 
  72. }else{ 
  73. $label = ''; 
  74.  
  75. if(isset($option['display_style'])) { 
  76. $display_style = $option['display_style']; 
  77. }else{ 
  78. $display_style = ''; 
  79.  
  80. if ( isset( $option['disabled'] ) AND $option['disabled'] ) { 
  81. $disabled = 'disabled'; 
  82. }else{ 
  83. $disabled = ''; 
  84.  
  85. $label = htmlspecialchars( $label, ENT_QUOTES ); 
  86.  
  87. $label = stripslashes( $label ); 
  88.  
  89. $label = str_replace( '&', '&', $label ); 
  90.  
  91. $field_label = $data['label']; 
  92.  
  93. if($list_show_value == 0) { 
  94. $value = $label; 
  95.  
  96.  
  97. if ( $selected_value == $value OR ( is_array( $selected_value ) AND in_array( $value, $selected_value ) ) ) { 
  98. $selected = 'selected'; 
  99. }else if( ( $selected_value == '' OR $selected_value == $field_label ) AND isset( $option['selected'] ) AND $option['selected'] == 1 ) { 
  100. $selected = 'selected'; 
  101. }else{ 
  102. $selected = ''; 
  103.  
  104. ?> 
  105. <option value="<?php echo $value;?>" <?php echo $selected;?> style="<?php echo $display_style;?>" <?php echo $disabled;?>><?php echo $label;?></option> 
  106. <?php 
  107. ?> 
  108. </select> 
  109. <?php 
  110. break; 
  111. case 'radio': 
  112. $x = 0; 
  113. if( $label_pos == 'left' OR $label_pos == 'above' ) { 
  114. ?><?php 
  115.  
  116. ?><input type="hidden" name="ninja_forms_field_<?php echo $field_id;?>" value=""><span id="ninja_forms_field_<?php echo $field_id;?>_options_span" class="<?php echo $list_options_span_class;?>" rel="<?php echo $field_id;?>"><ul><?php 
  117. foreach($options as $option) { 
  118.  
  119. if(isset($option['value'])) { 
  120. $value = $option['value']; 
  121. }else{ 
  122. $value = $option['label']; 
  123.  
  124. $value = htmlspecialchars( $value, ENT_QUOTES ); 
  125.  
  126. if(isset($option['label'])) { 
  127. $label = $option['label']; 
  128. }else{ 
  129. $label = ''; 
  130.  
  131. if(isset($option['display_style'])) { 
  132. $display_style = $option['display_style']; 
  133. }else{ 
  134. $display_style = ''; 
  135.  
  136. //$label = htmlspecialchars( $label, ENT_QUOTES ); 
  137.  
  138. $label = stripslashes($label); 
  139.  
  140. if($list_show_value == 0) { 
  141. $value = $label; 
  142.  
  143. if ( $selected_value == $value OR ( is_array( $selected_value ) AND in_array( $value, $selected_value ) ) ) { 
  144. $selected = 'checked'; 
  145. }else if( $selected_value == '' AND isset( $option['selected'] ) AND $option['selected'] == 1 ) { 
  146. $selected = 'checked'; 
  147. }else{ 
  148. $selected = ''; 
  149. ?><li><label id="ninja_forms_field_<?php echo $field_id;?>_<?php echo $x;?>_label" class="ninja-forms-field-<?php echo $field_id;?>-options" style="<?php echo $display_style;?>" for="ninja_forms_field_<?php echo $field_id;?>_<?php echo $x;?>"><input id="ninja_forms_field_<?php echo $field_id;?>_<?php echo $x;?>" name="ninja_forms_field_<?php echo $field_id;?>" type="radio" class="<?php echo $field_class;?>" value="<?php echo $value;?>" <?php echo $selected;?> rel="<?php echo $field_id;?>" /><?php echo $label;?></label></li><?php 
  150. $x++; 
  151. ?></ul></span><li style="display:none;" id="ninja_forms_field_<?php echo $field_id;?>_template"><label><input id="ninja_forms_field_<?php echo $field_id;?>_" name="" type="radio" class="<?php echo $field_class;?>" value="" rel="<?php echo $field_id;?>" /></label></li> 
  152. <?php 
  153. break; 
  154. case 'checkbox': 
  155. $x = 0; 
  156. ?><input type="hidden" id="ninja_forms_field_<?php echo $field_id;?>" name="ninja_forms_field_<?php echo $field_id;?>" value=""><span id="ninja_forms_field_<?php echo $field_id;?>_options_span" class="<?php echo $list_options_span_class;?>" rel="<?php echo $field_id;?>"><ul><?php 
  157. foreach($options as $option) { 
  158.  
  159. if(isset($option['value'])) { 
  160. $value = $option['value']; 
  161. }else{ 
  162. $value = $option['label']; 
  163.  
  164. $value = htmlspecialchars( $value, ENT_QUOTES ); 
  165.  
  166. if(isset($option['label'])) { 
  167. $label = $option['label']; 
  168. }else{ 
  169. $label = ''; 
  170.  
  171. if(isset($option['display_style'])) { 
  172. $display_style = $option['display_style']; 
  173. }else{ 
  174. $display_style = ''; 
  175.  
  176. //$label = htmlspecialchars( $label, ENT_QUOTES ); 
  177.  
  178. $label = stripslashes( $label) ; 
  179.  
  180. if($list_show_value == 0) { 
  181. $value = $label; 
  182.  
  183. if( isset( $option['selected'] ) AND $option['selected'] == 1 ) { 
  184. $checked = 'checked'; 
  185.  
  186. if( is_array( $selected_value ) AND in_array($value, $selected_value) ) { 
  187. $checked = 'checked'; 
  188. }else if($selected_value == $value) { 
  189. $checked = 'checked'; 
  190. }else if( $selected_value == '' AND isset( $option['selected'] ) AND $option['selected'] == 1 ) { 
  191. $checked = 'checked'; 
  192. }else{ 
  193. $checked = ''; 
  194.  
  195. ?><li><label id="ninja_forms_field_<?php echo $field_id;?>_<?php echo $x;?>_label" class="ninja-forms-field-<?php echo $field_id;?>-options" style="<?php echo $display_style;?>"><input id="ninja_forms_field_<?php echo $field_id;?>_<?php echo $x;?>" name="ninja_forms_field_<?php echo $field_id;?>[]" type="checkbox" class="<?php echo $field_class;?> ninja_forms_field_<?php echo $field_id;?>" value="<?php echo $value;?>" <?php echo $checked;?> rel="<?php echo $field_id;?>"/><?php echo $label;?></label></li><?php 
  196. $x++; 
  197. ?></ul></span><li style="display:none;" id="ninja_forms_field_<?php echo $field_id;?>_template"><label><input id="ninja_forms_field_<?php echo $field_id;?>_" name="" type="checkbox" class="<?php echo $field_class;?>" value="" rel="<?php echo $field_id;?>" /></label></li> 
  198. <?php 
  199. break; 
  200. case 'multi': 
  201. ?> 
  202. <select name="ninja_forms_field_<?php echo $field_id;?>[]" id="ninja_forms_field_<?php echo $field_id;?>" class="<?php echo $field_class;?>" multiple size="<?php echo $multi_size;?>" rel="<?php echo $field_id;?>" > 
  203. <?php 
  204. if($label_pos == 'inside') { 
  205. ?> 
  206. <option value=""><?php echo $label;?></option> 
  207. <?php 
  208. foreach($options as $option) { 
  209.  
  210. if(isset($option['value'])) { 
  211. $value = $option['value']; 
  212. }else{ 
  213. $value = $option['label']; 
  214.  
  215. $value = htmlspecialchars( $value, ENT_QUOTES ); 
  216.  
  217. if(isset($option['label'])) { 
  218. $label = $option['label']; 
  219. }else{ 
  220. $label = ''; 
  221.  
  222. if(isset($option['display_style'])) { 
  223. $display_style = $option['display_style']; 
  224. }else{ 
  225. $display_style = ''; 
  226.  
  227. $label = htmlspecialchars( $label, ENT_QUOTES ); 
  228.  
  229. $label = stripslashes($label); 
  230.  
  231. if($list_show_value == 0) { 
  232. $value = $label; 
  233.  
  234. if(is_array($selected_value) AND in_array($value, $selected_value)) { 
  235. $selected = 'selected'; 
  236. }else if( $selected_value == '' AND isset( $option['selected'] ) AND $option['selected'] == 1 ) { 
  237. $selected = 'selected'; 
  238. }else{ 
  239. $selected = ''; 
  240.  
  241. if( $display_style == '' ) { 
  242. ?> 
  243. <option value="<?php echo $value;?>" <?php echo $selected;?>><?php echo $label;?></option> 
  244. <?php 
  245. ?> 
  246. </select> 
  247. <select id="ninja_forms_field_<?php echo $field_id;?>_clone" style="display:none;" rel="<?php echo $field_id;?>" > 
  248. <?php 
  249. $x = 0; 
  250. foreach($options as $option) { 
  251.  
  252. if(isset($option['value'])) { 
  253. $value = $option['value']; 
  254. }else{ 
  255. $value = $option['label']; 
  256.  
  257. $value = htmlspecialchars( $value, ENT_QUOTES ); 
  258.  
  259. if(isset($option['label'])) { 
  260. $label = $option['label']; 
  261. }else{ 
  262. $label = ''; 
  263.  
  264. if(isset($option['display_style'])) { 
  265. $display_style = $option['display_style']; 
  266. }else{ 
  267. $display_style = ''; 
  268.  
  269. $label = htmlspecialchars( $label, ENT_QUOTES ); 
  270.  
  271. $label = stripslashes( $label ); 
  272.  
  273. if($list_show_value == 0) { 
  274. $value = $label; 
  275.  
  276. if(is_array($selected_value) AND in_array($value, $selected_value)) { 
  277. $selected = 'selected'; 
  278. }else{ 
  279. $selected = ''; 
  280.  
  281. if( $display_style != '' ) { 
  282. ?> 
  283. <option value="<?php echo $value;?>" title="<?php echo $x;?>" <?php echo $selected;?>><?php echo $label;?></option> 
  284. <?php 
  285. $x++; 
  286. ?> 
  287. </select> 
  288. <?php 
  289. break;