26 public static function register(
$field ) {
27 if ( ! is_subclass_of(
$field,
'GravityView_Field' ) ) {
28 throw new Exception(
'Must be a subclass of GravityView_Field' );
30 if ( empty(
$field->name ) ) {
31 throw new Exception(
'The name must be set' );
33 if ( isset( self::$_fields[
$field->name ] ) && ! defined(
'DOING_GRAVITYVIEW_TESTS' ) ) {
34 throw new Exception(
'Field type already registered: ' .
$field->name );
44 public static function create( $properties ) {
45 $type = isset( $properties[
'type'] ) ? $properties[
'type'] :
'';
46 $type = empty( $properties[
'inputType'] ) ? $type : $properties[
'inputType'];
47 if ( empty( $type ) || ! isset( self::$_fields[ $type ] ) ) {
50 $class = self::$_fields[ $type ];
51 $class_name = get_class(
$class );
52 $field =
new $class_name( $properties );
64 public static function exists( $field_name ) {
65 return isset( self::$_fields[
"{$field_name}"] );
74 return isset( self::$_fields[ $field_name ] ) ? self::$_fields[ $field_name ] :
false;
84 public static function get( $field_name ) {
85 return self::get_instance( $field_name );
99 foreach( self::$_fields as
$field ) {
100 if( $field_type === $field->_gf_field_class_name ) {
117 public static function get_all( $groups =
'' ) {
119 if(
'' !== $groups ) {
120 $return_fields = self::$_fields;
122 $groups = (array) $groups;
124 foreach ( $return_fields as $key =>
$field ) {
125 if( ! in_array(
$field->group, $groups,
true ) ) {
126 unset( $return_fields[ $key ] );
129 return $return_fields;
131 return self::$_fields;
Modify field settings by extending this class.
static create( $properties)
Wanted to extend GF_Fields, but couldn't because static variables are inherited, so $_fields would al...
static get_associated_field( $gf_field)
Alias for get_instance()
static exists( $field_name)
Does the field exist (has it been registered)?
static get_all( $groups='')
Get all fields.
static get_instance( $field_name)