Selector::field() method

Get the field(s) of this Selector

Note that if calling this as a property (rather than a method) it can return either a string or an array.

Available since version 3.0.42. Prior versions only supported the 'field' property.


// basic usage
$string = $selector->field();

// usage with all arguments
$string = $selector->field($forceString = true);


forceString (optional)bool, int

Specify one of the following:

  • true (bool): to only return a string, where multiple-fields will be split by pipe "|". (default)
  • false (bool): to return string if 1 field, or array of multiple fields (same behavior as field property).
  • 1 (int): to return only the first value (string).

Return value

string array null

See Also

Selector methods and properties

API reference based on ProcessWire core version 3.0.184

Twitter updates

  • ProcessWire 3.0.185 (dev) core updates, plus new Session Allow module— More
    17 September 2021
  • Three new ProcessWire Textformatter modules: Find/Replace, Markdown in Markup, and Emoji— More
    3 September 2021
  • This week we have a new master version released after a year in the making. With nearly 40 pull requests, hundreds of new additions and more than 100 issue reports resolved, this new version has a ton of great new stuff— More
    27 August 2021

Latest news

  • ProcessWire Weekly #385
    In the 385th issue of ProcessWire Weekly we'll cover the latest weekly update from Ryan, check out a new fieldtype module called Page Reference Context Data, and more. Read on! / 25 September 2021
  • ProcessWire 3.0.184 new master/main version
    This week we have a new master/main version released after a full year in the making. As you might imagine, this new version has a ton of great new stuff and we’ll try to cover much of it here.
    Blog / 27 August 2021
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH