public static function getGroupedFields($formatString, FieldOverrides $fieldOverrides = null)
    {
        $groupedFields = [];
        $hiddenFields = $fieldOverrides ? $fieldOverrides->getHiddenFields() : [];
        $expression = '/\%(' . implode('|', AddressField::getAll()) . ')/';
        $formatLines = explode("\n", $formatString);
        foreach ($formatLines as $index => $formatLine) {
            preg_match_all($expression, $formatLine, $foundTokens);
            foreach ($foundTokens[0] as $token) {
                $field = substr($token, 1);
                if (!in_array($field, $hiddenFields)) {
                    $groupedFields[$index][] = substr($token, 1);
                }
            }
        }
        // The indexes won't be sequential if there were any rows
        // without tokens, so reset them.
        $groupedFields = array_values($groupedFields);

        return $groupedFields;
    }
public static function getGroupedFields($formatString, FieldOverrides $fieldOverrides = null)
    {
        $groupedFields = [];
        $hiddenFields = $fieldOverrides ? $fieldOverrides->getHiddenFields() : [];
        $expression = '/\%(' . implode('|', AddressField::getAll()) . ')/';
        $formatLines = explode("\n", $formatString);
        foreach ($formatLines as $index => $formatLine) {
            preg_match_all($expression, $formatLine, $foundTokens);
            foreach ($foundTokens[0] as $token) {
                $field = substr($token, 1);
                if (!in_array($field, $hiddenFields)) {
                    $groupedFields[$index][] = substr($token, 1);
                }
            }
        }
        // The indexes won't be sequential if there were any rows
        // without tokens, so reset them.
        $groupedFields = array_values($groupedFields);

        return $groupedFields;
    }
public static function getGroupedFields ( $ formatString , FieldOverrides $ fieldOverrides = null ) { $ groupedFields = [ ] ; $ hiddenFields = $ fieldOverrides ? $ fieldOverrides -> getHiddenFields ( ) : [ ] ; $ expression = '/\%(' . implode ( '|' , AddressField :: getAll ( ) ) . ')/' ; $ formatLines = explode ( "\n" , $ formatString ) ; foreach ( $ formatLines as $ index => $ formatLine ) { preg_match_all ( $ expression , $ formatLine , $ foundTokens ) ; foreach ( $ foundTokens [ 0 ] as $ token ) { $ field = substr ( $ token , 1 ) ; if ( ! in_array ( $ field , $ hiddenFields ) ) { $ groupedFields [ $ index ] [ ] = substr ( $ token , 1 ) ; } } } // The indexes won't be sequential if there were any rows // without tokens, so reset them. $ groupedFields = array_values ( $ groupedFields ) ; return $ groupedFields ; }
Gets the list of used fields, grouped by line.

Used for generating address forms.

Applies field overrides, to ensure hidden fields are skipped.

@param string         $formatString   The format string.
@param FieldOverrides $fieldOverrides The field overrides.

@return array An array of address fields grouped by line, in the same
order as they appear in the format string. For example:
[
[givenName, familyName],
[organization],
[addressLine1],
[addressLine2],
[locality, administrativeArea, postalCode]
]
Gets the list of used fields grouped by line .