nf_field_list_edit_sub_value

Edit submission value output function.

Description

nf_field_list_edit_sub_value( $field_id, $user_value, $field ); 

Parameters (3)

0. $field_id
The field id.
1. $user_value
The user value.
2. $field
The field.

Usage

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

Defined (1)

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

/deprecated/includes/fields/list.php  
  1. function nf_field_list_edit_sub_value( $field_id, $user_value, $field ) { 
  2. $label = $field['data']['label']; 
  3. $label_pos = $field['data']['label_pos']; 
  4. $selected_value = $user_value; 
  5. $options = $field['data']['list']['options']; 
  6.  
  7. $field_class = isset( $field['data']['class'] ) ? $field['data']['class'] : ''; 
  8.  
  9. if( isset( $field['data']['list_show_value'] ) ) { 
  10. $list_show_value = $field['data']['list_show_value']; 
  11. }else{ 
  12. $list_show_value = 0; 
  13. switch( $field['data']['list_type'] ) { 
  14. case 'dropdown': 
  15. ?> 
  16. <select name="fields[<?php echo $field_id; ?>]" id="ninja_forms_field_<?php echo $field_id;?>" class="<?php echo $field_class;?>" rel="<?php echo $field_id;?>"> 
  17. <?php 
  18. if($label_pos == 'inside') { 
  19. ?> 
  20. <option value=""><?php echo $label;?></option> 
  21. <?php 
  22. foreach( $options as $option ) { 
  23.  
  24. if(isset($option['value'])) { 
  25. $value = $option['value']; 
  26. }else{ 
  27. $value = $option['label']; 
  28.  
  29. $value = htmlspecialchars( $value, ENT_QUOTES ); 
  30.  
  31. if(isset($option['label'])) { 
  32. $label = $option['label']; 
  33. }else{ 
  34. $label = ''; 
  35.  
  36. if(isset($option['display_style'])) { 
  37. $display_style = $option['display_style']; 
  38. }else{ 
  39. $display_style = ''; 
  40.  
  41. if ( isset( $option['disabled'] ) AND $option['disabled'] ) { 
  42. $disabled = 'disabled'; 
  43. }else{ 
  44. $disabled = ''; 
  45.  
  46. $label = htmlspecialchars( $label, ENT_QUOTES ); 
  47.  
  48. $label = stripslashes( $label ); 
  49.  
  50. $label = str_replace( '&', '&', $label ); 
  51.  
  52. $field_label = $field['data']['label']; 
  53.  
  54. if($list_show_value == 0) { 
  55. $value = $label; 
  56.  
  57. if ( $selected_value == $value OR ( is_array( $selected_value ) AND in_array( $value, $selected_value ) ) ) { 
  58. $selected = 'selected'; 
  59. }else if( ( $selected_value == '' OR $selected_value == $field_label ) AND isset( $option['selected'] ) AND $option['selected'] == 1 ) { 
  60. $selected = 'selected'; 
  61. }else{ 
  62. $selected = ''; 
  63.  
  64. ?> 
  65. <option value="<?php echo $value;?>" <?php echo $selected;?> style="<?php echo $display_style;?>" <?php echo $disabled;?>><?php echo $label;?></option> 
  66. <?php 
  67. ?> 
  68. </select> 
  69. <?php 
  70. break; 
  71. case 'radio': 
  72. ?> 
  73. <input type="hidden" name="fields[<?php echo $field_id; ?>]" value=""><ul><?php 
  74. foreach($options as $option) { 
  75.  
  76. if(isset($option['value'])) { 
  77. $value = $option['value']; 
  78. }else{ 
  79. $value = $option['label']; 
  80.  
  81. $value = htmlspecialchars( $value, ENT_QUOTES ); 
  82.  
  83. if(isset($option['label'])) { 
  84. $label = $option['label']; 
  85. }else{ 
  86. $label = ''; 
  87.  
  88. if(isset($option['display_style'])) { 
  89. $display_style = $option['display_style']; 
  90. }else{ 
  91. $display_style = ''; 
  92.  
  93. $label = htmlspecialchars( $label, ENT_QUOTES ); 
  94.  
  95. $label = stripslashes($label); 
  96.  
  97. if($list_show_value == 0) { 
  98. $value = $label; 
  99.  
  100. if ( $selected_value == $value OR ( is_array( $selected_value ) AND in_array( $value, $selected_value ) ) ) { 
  101. $selected = 'checked'; 
  102. }else if( $selected_value == '' AND isset( $option['selected'] ) AND $option['selected'] == 1 ) { 
  103. $selected = 'checked'; 
  104. }else{ 
  105. $selected = ''; 
  106. ?> 
  107. <li> 
  108. <label><input id="" name="fields[<?php echo $field_id; ?>]" type="radio" class="<?php echo $field_class;?>" value="<?php echo $value;?>" <?php echo $selected;?> /><?php echo $label;?></label> 
  109. </li> 
  110. <?php 
  111.  
  112. ?></ul> 
  113. <?php 
  114. break; 
  115. case 'checkbox': 
  116.  
  117. ?><input type="hidden" name="fields[<?php echo $field_id; ?>][]" value=""><ul><?php 
  118. foreach($options as $option) { 
  119.  
  120. if(isset($option['value'])) { 
  121. $value = $option['value']; 
  122. }else{ 
  123. $value = $option['label']; 
  124.  
  125. $value = htmlspecialchars( $value, ENT_QUOTES ); 
  126.  
  127. if(isset($option['label'])) { 
  128. $label = $option['label']; 
  129. }else{ 
  130. $label = ''; 
  131.  
  132. if(isset($option['display_style'])) { 
  133. $display_style = $option['display_style']; 
  134. }else{ 
  135. $display_style = ''; 
  136.  
  137. $label = htmlspecialchars( $label, ENT_QUOTES ); 
  138.  
  139. $label = stripslashes( $label) ; 
  140.  
  141. if($list_show_value == 0) { 
  142. $value = $label; 
  143.  
  144. if( isset( $option['selected'] ) AND $option['selected'] == 1 ) { 
  145. $checked = 'checked'; 
  146.  
  147. if( is_array( $selected_value ) AND in_array($value, $selected_value) ) { 
  148. $checked = 'checked'; 
  149. }else if($selected_value == $value) { 
  150. $checked = 'checked'; 
  151. }else if( $selected_value == '' AND isset( $option['selected'] ) AND $option['selected'] == 1 ) { 
  152. $checked = 'checked'; 
  153. }else{ 
  154. $checked = ''; 
  155.  
  156. ?> 
  157. <li> 
  158. <label> 
  159. <input id="" name="fields[<?php echo $field_id; ?>][]" type="checkbox" value="<?php echo $value;?>" <?php echo $checked;?> /> <?php echo $label;?> 
  160. </label> 
  161.  
  162. </li> 
  163. <?php 
  164. ?></ul> 
  165. <?php 
  166. break; 
  167. case 'multi'; 
  168. ?> 
  169. <select name="fields[<?php echo $field_id; ?>][]" multiple size="5"> 
  170. <?php 
  171. if($label_pos == 'inside') { 
  172. ?> 
  173. <option value=""><?php echo $label;?></option> 
  174. <?php 
  175. foreach($options as $option) { 
  176.  
  177. if(isset($option['value'])) { 
  178. $value = $option['value']; 
  179. }else{ 
  180. $value = $option['label']; 
  181.  
  182. $value = htmlspecialchars( $value, ENT_QUOTES ); 
  183.  
  184. if(isset($option['label'])) { 
  185. $label = $option['label']; 
  186. }else{ 
  187. $label = ''; 
  188.  
  189. if(isset($option['display_style'])) { 
  190. $display_style = $option['display_style']; 
  191. }else{ 
  192. $display_style = ''; 
  193.  
  194. $label = htmlspecialchars( $label, ENT_QUOTES ); 
  195.  
  196. $label = stripslashes($label); 
  197.  
  198. if($list_show_value == 0) { 
  199. $value = $label; 
  200.  
  201. if(is_array($selected_value) AND in_array($value, $selected_value)) { 
  202. $selected = 'selected'; 
  203. }else if( $selected_value == '' AND isset( $option['selected'] ) AND $option['selected'] == 1 ) { 
  204. $selected = 'selected'; 
  205. }else{ 
  206. $selected = ''; 
  207.  
  208. if( $display_style == '' ) { 
  209. ?> 
  210. <option value="<?php echo $value;?>" <?php echo $selected;?>><?php echo $label;?></option> 
  211. <?php 
  212. ?> 
  213. </select> 
  214. <?php 
  215. break;