Field System - Configuration Array

The Field System Array is designed to store field related information, the information will be used in various objects under different circumstances. Like for example the translation key will be used as the array key map when integrating field dynamic strings to WPML plugin for translation.

  /**
     * Example of valid property fields registration
     * array, you can inject this array via field related hooks
     */
    $registry['property_duration'] = array(
      'field' => 'property_duration',
      'name' => __('Duration', 'victheme_property'),
      'label' => __('Availability', 'victheme_property'),
      'enabled' => true,
      'icons' => array(
        'icon' => 'real8',
        'family' => 'proicon',
      ),
      'settings' => array(
        'separator' => array(
          'mode' => 'data',
          'type' => 'VTCore_Bootstrap_Form_BsText',
          'context' => array(
            'text' => __('Separator', 'victheme_property'),
            'description' => __('Configure the text for the separator element', 'victheme_property'),
            'value' => __('To', 'victheme_property'),
          ),
        ),
        'format' => array(
          'mode' => 'data',
          'type' => 'VTCore_Bootstrap_Form_BsText',
          'context' => array(
            'text' => __('Date Format', 'victheme_property'),
            'description' => __('Configure the text for the separator element', 'victheme_property'),
            'value' => 'd/m/Y',
          ),
        ),
      ),
      'storage' => array(
        'from' => array(
          'type' => 'meta',
          'mode' => 'timestamp',
          'target' => '_property_duration_from',
        ),
        'end' => array(
          'type' => 'meta',
          'mode' => 'timestamp',
          'target' => '_property_duration_end',
        ),
      ),
      'translation' => array(
        'search.label',
        'search.settings.from.context.value',
        'search.settings.separator.context.value',
        'search.settings.end.context.value',
        'settings.separator.context.value',
        'metabox.settings.from.context.value',
        'metabox.settings.end.context.value',
      ),
      'search' => array(
        'label' => __('Availability', 'victheme_property'),
        'settings' => array(
          'from' => array(
            'type' => 'VTCore_Bootstrap_Form_BsText',
            'context' => array(
              'text' => __('From Date Form Label', 'victheme_property'),
              'description' => __('Configure the text for the from date search form label text', 'victheme_property'),
              'value' => __('Availability Start Date', 'victheme_property'),
            ),
          ),
          'separator' => array(
            'type' => 'VTCore_Bootstrap_Form_BsText',
            'context' => array(
              'text' => __('Separator Date Form Label', 'victheme_property'),
              'description' => __('Configure the text for the separator search form label text', 'victheme_property'),
              'value' => __('to', 'victheme_property'),
            ),
          ),
          'end' => array(
            'type' => 'VTCore_Bootstrap_Form_BsText',
            'context' => array(
              'text' => __('End Date Form Label', 'victheme_property'),
              'description' => __('Configure the text for the end date search form label text', 'victheme_property'),
              'value' => __('Availability End Date', 'victheme_property'),
            ),
          ),
        ),
      ),
      'metabox' => array(
        'label' => __('Duration', 'victheme_property'),
        'description' => __('Set the availability duration for this property.', 'victheme_property'),
        'settings' => array(
          'from' => array(
            'type' => 'VTCore_Bootstrap_Form_BsText',
            'context' => array(
              'text' => __('From Form Label', 'victheme_property'),
              'description' => __('Configure the text for the from form label text', 'victheme_property'),
              'value' => __('From Date', 'victheme_property'),
            ),
          ),
          'end' => array(
            'type' => 'VTCore_Bootstrap_Form_BsText',
            'context' => array(
              'text' => __('End Form Label', 'victheme_property'),
              'description' => __('Configure the text for the end form label text', 'victheme_property'),
              'value' => __('End Date', 'victheme_property'),
            ),
          ),
        ),
      ),
      'objects' => array(
        'metabox' => 'VTCore_Property_Form_Metabox_Duration',
        'search' => 'VTCore_Property_Form_Search_Duration',
        'display'=> 'VTCore_Property_Element_Duration',
      ),
      'visibility' => array(
        'from' => true,
        'separator' => true,
        'end' => true,
        'label' => true,
        'icon' => true,
        'search' => true,
      ),
      'group' => 'property_info',
      'weight' => 1,
    );

 

field

The field key is the field machine name, this field string entry must be unique



name

This field key is for storing the field human readable name, this is most likely to be used for the front end field label or as a fallback if the field doesn’t have any special labeling for search, metabox and front end display.



enabled

This field is for turning on / off a field instantly.



label

The string text for the field form label element, this will be served as the default fallback value if the field hasn’t defined string for metabox and search form label field.



icons

The icon array context for VTCore_Wordpress_Element_WpIcon object. By using the VTCore icon objects you can access all the icons defined via VTCore Icon Factory and if any theme or plugin register additional icon set to the library, it will also available for field to use.



settings

It is possible to define custom settings context that will be used when creating the field management form, this way you can always create a field that can be customized via WordPress backend easily.



storage

Define the field data storage behavior, you can have multiple storage point in a single field. Valid storage types are taxonomy terms, metadata and data (serialized data in a single _property_data post meta.



translation

Define the array key in dotted notation format referencing the field array context for marking that the array value defined in the defined array key will be passed through WPML hooks for registering it as a custom strings ready for translation.



translation

Define the array key in dotted notation format referencing the field array context for marking that the array value defined in the defined array key will be passed through WPML hooks for registering it as a custom strings ready for translation.



search

The search branch in the array context is for mapping context that will be passed to the field configuration GUI and the field form when in search mode.



visibility

Define what should be displayed globally, this will be used when building field front end display, search form and metabox form.



objects

Define the PHP class name that will be used when building the front end display, search form field and metabox form field. The property entity responsible for building the object will assume that the class name is either already loaded or eligible for autoloading. if it isn’t available due to any reasons the field will not build the output for field mode.



group

This is used mainly in metabox mode only, the purpose is to determine on which accordion group that the related plugin should be inserted to.



weight

The weight for ordering the field when rendered

 

Show All