src/fieldwork/Form.php
public function f ($query, $includeInactiveFields = false)
    {
        $minLength = -1;
        $match     = null;
        foreach ($this->getFields($includeInactiveFields) as $field)
            /* @var $field Field */
            if (preg_match("/^(.*)" . preg_quote($query) . "$/", $field->getGlobalSlug(), $matches)) {
                $l = strlen($matches[1]);
                if ($l < $minLength || $minLength == -1) {
                    $minLength = $l;
                    $match     = $field;
                }
            }
        return $match;
    }
public function f ($query, $includeInactiveFields = false)
    {
        $minLength = -1;
        $match     = null;
        foreach ($this->getFields($includeInactiveFields) as $field)
            /* @var $field Field */
            if (preg_match("/^(.*)" . preg_quote($query) . "$/", $field->getGlobalSlug(), $matches)) {
                $l = strlen($matches[1]);
                if ($l < $minLength || $minLength == -1) {
                    $minLength = $l;
                    $match     = $field;
                }
            }
        return $match;
    }
public function f ( $ query , $ includeInactiveFields = false ) { $ minLength = - 1 ; $ match = null ; foreach ( $ this -> getFields ( $ includeInactiveFields ) as $ field ) /* @var $field Field */ if ( preg_match ( "/^(.*)" . preg_quote ( $ query ) . "$/" , $ field -> getGlobalSlug ( ) , $ matches ) ) { $ l = strlen ( $ matches [ 1 ] ) ; if ( $ l < $ minLength || $ minLength == - 1 ) { $ minLength = $ l ; $ match = $ field ; } } return $ match ; }
Searches form fields

@param string $query                 ID to search for
@param bool   $includeInactiveFields Whether to include inactive fields in the search

@return null|Field closest match or null if not found
Searches form fields