<?php if ( ! defined( 'ABSPATH' ) ) exit;
* Class NF_Fields_Unknown
class NF_Fields_Unknown extends NF_Fields_Hidden
protected $_name = 'unknown';
protected $_type = 'unknown';
protected $_section = '';
protected $_icon = 'question';
protected $_templates = 'null';
protected $_aliases = array();
protected $_settings_only = array(
public function __construct()
$this->_nicename = esc_html__( 'Unknown', 'ninja-forms' );
$this->_settings[ 'message' ] = array(
$this->_settings[ 'label' ][ 'group' ] = '';
unset( $this->_settings[ 'default' ] ); // TODO: Seeing an error when removing default form the $_settings_only property, so just unsetting it here for now.
add_filter( 'nf_sub_hidden_field_types', array( $this, 'hide_field_type' ) );
public function validate( $field, $data )
return array(); // Return empty array with no errors.
function hide_field_type( $field_types )
$field_types[] = $this->_name;
public static function create( $field )
$unknown = Ninja_Forms()->form()->field()->get();
if( is_object( $field ) ){
$unknown->update_settings(array(
'id' => $field->get_id(),
'label' => $field->get_setting( 'label' ),
'order' => $field->get_setting( 'order' ),
'key' => $field->get_setting( 'key' ),
'message' => sprintf( esc_html__( 'Field type "%s" not found.', 'ninja-forms' ), $field->get_setting( 'type' ) )
} elseif( isset( $field[ 'settings' ] ) ){
$unknown->update_settings(array(
'label' => $field[ 'settings' ][ 'label' ],
'order' => $field[ 'settings' ][ 'order' ],
'key' => $field[ 'settings' ][ 'key' ],
'message' => sprintf( esc_html__( 'Field type "%s" not found.', 'ninja-forms' ), $field[ 'settings' ][ 'type' ] )
$unknown->update_settings(array(
'label' => $field[ 'label' ],
'order' => $field[ 'order' ],
'key' => $field[ 'key' ],
'message' => sprintf( esc_html__( 'Field type "%s" not found.', 'ninja-forms' ), $field[ 'type' ] )