nf_field_text_edit_default_value

The Ninja Forms nf field text edit default value function.

Description

nf_field_text_edit_default_value( $field_id, $data ); 

Parameters (2)

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

Usage

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

Defined (1)

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

/deprecated/includes/fields/textbox.php  
  1. function nf_field_text_edit_default_value( $field_id, $data ) { 
  2. $field = ninja_forms_get_field_by_id( $field_id ); 
  3. if ( '_text' != $field['type'] ) 
  4. return false; 
  5.  
  6. $plugin_settings = nf_get_settings(); 
  7.  
  8. $currency_symbol = isset( $plugin_settings['currency_symbol'] ) ? $plugin_settings['currency_symbol'] : "$"; 
  9. $date_format = isset( $plugin_settings['date_format'] ) ? $plugin_settings['date_format'] : "m/d/Y"; 
  10. $default_value = isset( $data['default_value'] ) ? $data['default_value'] : ''; 
  11. $default_value_type = isset( $data['default_value_type'] ) ? $data['default_value_type'] : ''; 
  12. $custom = ''; 
  13.  
  14. if( $default_value == 'none' ) { 
  15. $default_value = ''; 
  16.  
  17. ?> 
  18. <div class="description description-thin"> 
  19. <span class="field-option"> 
  20. <label for=""> 
  21. <?php _e( 'Default Value' , 'ninja-forms'); ?> 
  22. </label><br /> 
  23. <select id="default_value_<?php echo $field_id;?>" name="ninja_forms_field_<?php echo $field_id;?>[default_value_type]" class="widefat ninja-forms-_text-default-value"> 
  24. <option value="" <?php if( $default_value == '') { echo 'selected'; $custom = 'no';}?>><?php _e('None', 'ninja-forms'); ?></option> 
  25. <option value="_user_id" <?php if($default_value == '_user_id') { echo 'selected'; $custom = 'no';}?>><?php _e('User ID (If logged in)', 'ninja-forms'); ?></option> 
  26. <option value="_user_firstname" <?php if($default_value == '_user_firstname') { echo 'selected'; $custom = 'no';}?>><?php _e('User Firstname (If logged in)', 'ninja-forms'); ?></option> 
  27. <option value="_user_lastname" <?php if($default_value == '_user_lastname') { echo 'selected'; $custom = 'no';}?>><?php _e('User Lastname (If logged in)', 'ninja-forms'); ?></option> 
  28. <option value="_user_display_name" <?php if($default_value == '_user_display_name') { echo 'selected'; $custom = 'no';}?>><?php _e('User Display Name (If logged in)', 'ninja-forms'); ?></option> 
  29. <option value="_user_email" <?php if($default_value == '_user_email') { echo 'selected'; $custom = 'no';}?>><?php _e('User Email (If logged in)', 'ninja-forms'); ?></option> 
  30. <option value="post_id" <?php if($default_value == 'post_id') { echo 'selected'; $custom = 'no';}?>><?php _e('Post / Page ID (If available)', 'ninja-forms'); ?></option> 
  31. <option value="post_title" <?php if($default_value == 'post_title') { echo 'selected'; $custom = 'no';}?>><?php _e('Post / Page Title (If available)', 'ninja-forms'); ?></option> 
  32. <option value="post_url" <?php if($default_value == 'post_url') { echo 'selected'; $custom = 'no';}?>><?php _e('Post / Page URL (If available)', 'ninja-forms'); ?></option> 
  33. <option value="today" <?php if($default_value == 'today') { echo 'selected'; $custom = 'no';}?>><?php _e('Today\'s Date', 'ninja-forms'); ?></option> 
  34. <option value="_custom" <?php if($custom != 'no') { echo 'selected';}?>><?php _e('Custom', 'ninja-forms'); ?> -></option> 
  35. <option value="querystring" <?php if($default_value_type == 'querystring') { echo 'selected'; $custom = 'yes';}?>><?php _e('Querystring Variable', 'ninja-forms'); ?> -></option> 
  36. </select> 
  37. </span> 
  38. </div> 
  39. <div class="description description-thin"> 
  40.  
  41. <label for="" id="default_value_label_<?php echo $field_id;?>" style="<?php if($custom == 'no') { echo 'display:none;';}?>"> 
  42. <br /> 
  43. <input type="text" class="widefat code nf-default-value-text" name="ninja_forms_field_<?php echo $field_id;?>[default_value]" id="ninja_forms_field_<?php echo $field_id;?>_default_value" value="<?php echo $default_value;?>" data-field-id="<?php echo $field_id; ?>" /> 
  44. <span class="querystring-error" style="display:none;"><?php _e( 'This keyword is reserved by WordPress. Please try another.', 'ninja-forms' ); ?></span> 
  45. </label> 
  46.  
  47.  
  48. </div> 
  49. <?php