NF_Fields_Unknown

Class NF_Fields_Unknown.

Defined (1)

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

/includes/Fields/Unknown.php  
  1. class NF_Fields_Unknown extends NF_Fields_Hidden 
  2. protected $_name = 'unknown'; 
  3.  
  4. protected $_type = 'unknown'; 
  5.  
  6. protected $_section = ''; 
  7.  
  8. protected $_icon = 'question'; 
  9.  
  10. protected $_templates = 'null'; 
  11.  
  12. protected $_aliases = array(); 
  13.  
  14. protected $_settings_only = array( 
  15. 'label', 'default' 
  16. ); 
  17.  
  18. public function __construct() 
  19. parent::__construct(); 
  20.  
  21. $this->_nicename = __( 'Unknown', 'ninja-forms' ); 
  22.  
  23. $this->_settings[ 'message' ] = array( 
  24. 'name' => 'message',  
  25. 'type' => 'html',  
  26. 'label' => '',  
  27. 'width' => 'full',  
  28. 'group' => 'primary',  
  29. ); 
  30.  
  31. $this->_settings[ 'label' ][ 'group' ] = ''; 
  32.  
  33. unset( $this->_settings[ 'default' ] ); // TODO: Seeing an error when removing default form the $_settings_only property, so just unsetting it here for now. 
  34.  
  35. add_filter( 'nf_sub_hidden_field_types', array( $this, 'hide_field_type' ) ); 
  36.  
  37. public function validate( $field, $data ) 
  38. return array(); // Return empty array with no errors. 
  39.  
  40. function hide_field_type( $field_types ) 
  41. $field_types[] = $this->_name; 
  42. return $field_types; 
  43.  
  44. public static function create( $field ) 
  45. $unknown = Ninja_Forms()->form()->field()->get(); 
  46. if( is_object( $field ) ) { 
  47. $unknown->update_settings(array( 
  48. 'id' => $field->get_id(),  
  49. 'label' => $field->get_setting( 'label' ),  
  50. 'order' => $field->get_setting( 'order' ),  
  51. 'key' => $field->get_setting( 'key' ),  
  52. 'type' => 'unknown',  
  53. 'message' => sprintf( __( 'Field type "%s" not found.', 'ninja-forms' ), $field->get_setting( 'type' ) ) 
  54. )); 
  55. } elseif( isset( $field[ 'settings' ] ) ) { 
  56. $unknown->update_settings(array( 
  57. 'id' => $field[ 'id' ],  
  58. 'label' => $field[ 'settings' ][ 'label' ],  
  59. 'order' => $field[ 'settings' ][ 'order' ],  
  60. 'key' => $field[ 'settings' ][ 'key' ],  
  61. 'type' => 'unknown',  
  62. 'message' => sprintf( __( 'Field type "%s" not found.', 'ninja-forms' ), $field[ 'settings' ][ 'type' ] ) 
  63. )); 
  64. } else { 
  65. $unknown->update_settings(array( 
  66. 'id' => $field[ 'id' ],  
  67. 'label' => $field[ 'label' ],  
  68. 'order' => $field[ 'order' ],  
  69. 'key' => $field[ 'key' ],  
  70. 'type' => 'unknown',  
  71. 'message' => sprintf( __( 'Field type "%s" not found.', 'ninja-forms' ), $field[ 'type' ] ) 
  72. )); 
  73. return $unknown;