public class FieldManager

class.fieldmanager.php #12

The FieldManager class is responsible for managing all fields types in Symphony. Fields are stored on the file system either in the /fields folder of TOOLKIT or in a fields folder in an extension directory.


static string __getClassName(string $type)

Given a type, returns the full class name of a Field. Fields use a 'field' prefix

  • $type stringA field handle

static string|boolean __getClassPath(string $type)

Finds a Field by type by searching the TOOLKIT . /fields folder and then any fields folders in the installed extensions. The function returns the path to the folder where the field class resides.

  • $type stringThe field handle, that is, field.{$handle}.php

static string __getDriverPath(string $type)

Given a field type, return the path to it's class

  • $type stringThe handle of the field to load (it's type)

See Also
static string __getHandleFromFilename(string $filename)

Given the filename of a Field, return it's handle. This will remove the Symphony conventions of field.*.php

  • $filename stringThe filename of the Field

static boolean about(mixed $name)

This function is not implemented by the FieldManager class

static integer|boolean add(array $fields)

Given an associative array of fields, insert them into the database returning the resulting Field ID if successful, or false if there was an error. As fields are saved in order on a section, a query is made to determine the sort order of this field to be current sort order +1.

  • $fields arrayAssociative array of field names => values for the Field object


Returns a Field ID of the created Field on success, false otherwise.

static Field create(string $type)

Creates an instance of a given class and returns it. Adds the instance to the $_pool array with the key being the handle.

  • $type stringThe handle of the Field to create (which is it's handle)

static boolean delete(integer $id)

Given a Field ID, delete a Field from Symphony. This will remove the field from the fields table, all of the data stored in this field's tbl_entries_data_$id any existing section associations. This function additionally call the Field's tearDown method so that it can cleanup any additional settings or entry tables it may of created.

  • $id integerThe ID of the Field that should be deleted

static boolean edit(integer $id, array $fields)

Given a Field ID and associative array of fields, update an existing Field row in the tbl_fieldstable. Returns boolean for success/failure

  • $id integerThe ID of the Field that should be updated

  • $fields arrayAssociative array of field names => values for the Field object This array does need to contain every value for the field object, it can just be the changed values.

static array fetch(integer|array $id, integer $section_id, string $order, string $sortfield, string $type, string $location, string $where, integer|string $restrict)

The fetch method returns a instance of a Field from tbl_fields. The most common use of this function is to retrieve a Field by ID, but it can be used to retrieve Fields from a Section also. There are several parameters that can be used to fetch fields by their Type, Location, by a Field Constant or with a custom WHERE query.

  • $id integer|arrayThe ID of the field to retrieve. Defaults to null which will return multiple field objects. Since Symphony 2.3, $id will accept an array of Field ID's

  • $section_id integerThe ID of the section to look for the fields in. Defaults to null which will allow all fields in the Symphony installation to be searched on.

  • $order stringAvailable values of ASC (Ascending) or DESC (Descending), which refer to the sort order for the query. Defaults to ASC (Ascending)

  • $sortfield stringThe field to sort the query by. Can be any from the tbl_fields schema. Defaults to 'sortorder'

  • $type stringFilter fields by their type, ie. input, select. Defaults to null

  • $location stringFilter fields by their location in the entry form. There are two possible values, 'main' or 'sidebar'. Defaults to null

  • $where stringAllows a custom where query to be included. Must be valid SQL. The tbl_fields alias is t1

  • $restrict integer|stringOnly return fields if they match one of the Field Constants. Available values are __TOGGLEABLE_ONLY__, __UNTOGGLEABLE_ONLY__, __FILTERABLE_ONLY__, __UNFILTERABLE_ONLY__ or __FIELD_ALL__. Defaults to __FIELD_ALL__


An array of Field objects. If no Field are found, null is returned.

static mixed fetchFieldIDFromElementName(string|array $element_name, integer $section_id)

Given an $element_name and a $section_id, return the Field ID. Symphony enforces a uniqueness constraint on a section where every field must have a unique label (and therefore handle) so whilst it is impossible to have two fields from the same section, it would be possible to have two fields with the same name from different sections. Passing the $section_id lets you to specify which section should be searched. If $element_name is null, this function will return all the Field ID's from the given $section_id.

  • $element_name string|arrayThe handle of the Field label, or an array of handles. These handles may contain a mode as well, eg. title: formatted.

  • $section_id integerThe section that this field belongs too The field ID, or an array of field ID's

static string fetchFieldTypeFromID(integer $id)

Given a field ID, return the type of the field by querying tbl_fields

static array fetchFieldsSchema(integer $section_id)

Given a $section_id, this function returns an array of the installed fields schema. This includes the id, element_name, type and location.


An associative array that contains four keys, id, element_name, type and location

static string fetchHandleFromID(integer $id)

Given a field ID, return the handle of the field by querying tbl_fields

static integer fetchNextSortOrder()

Work out the next available sort order for a new field


Returns the next sort order

static boolean isFieldUsed(string $field_type)

Return boolean if the given $field_type is in use anywhere in the current Symphony install.

static boolean isTextFormatterUsed(string $text_formatter_handle)

Check if a specific text formatter is used by a Field

  • $text_formatter_handle stringThe handle of the TextFormatter


true if used, false if not

static array listAll()

Returns an array of all available field handles discovered in the TOOLKIT . /fields or EXTENSIONS . /extension_handle/fields.


A single dimensional array of field handles.

static boolean saveSettings(integer $field_id, array $settings)

Save the settings for a Field given it's $field_id and an associative array of settings.

  • $field_id integerThe ID of the field

  • $settings arrayAn associative array of settings, where the key is the column name and the value is the value.


true on success, false on failure

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details