src/Pages/MemberProfilePage.php
public function Fields()
    {
        $list     = $this->getComponents('Fields');
        $fields   = singleton(Member::class)->getMemberFormFields()->dataFields();
        $included = array();

        foreach ($list as $profileField) {
            if (!array_key_exists($profileField->MemberField, $fields)) {
                $profileField->delete();
            } else {
                $included[] = $profileField->MemberField;
            }
        }

        foreach ($fields as $name => $field) {
            if (!in_array($name, $included)) {
                $profileField = new MemberProfileField();
                $profileField->MemberField = $name;

                if (isset(self::$profile_field_defaults[$name])) {
                    $profileField->update(self::$profile_field_defaults[$name]);
                }

                $list->add($profileField);
            }
        }

        return $list;
    }
public function Fields()
    {
        $list     = $this->getComponents('Fields');
        $fields   = singleton(Member::class)->getMemberFormFields()->dataFields();
        $included = array();

        foreach ($list as $profileField) {
            if (!array_key_exists($profileField->MemberField, $fields)) {
                $profileField->delete();
            } else {
                $included[] = $profileField->MemberField;
            }
        }

        foreach ($fields as $name => $field) {
            if (!in_array($name, $included)) {
                $profileField = new MemberProfileField();
                $profileField->MemberField = $name;

                if (isset(self::$profile_field_defaults[$name])) {
                    $profileField->update(self::$profile_field_defaults[$name]);
                }

                $list->add($profileField);
            }
        }

        return $list;
    }
public function Fields ( ) { $ list = $ this -> getComponents ( 'Fields' ) ; $ fields = singleton ( Member :: class ) -> getMemberFormFields ( ) -> dataFields ( ) ; $ included = array ( ) ; foreach ( $ list as $ profileField ) { if ( ! array_key_exists ( $ profileField -> MemberField , $ fields ) ) { $ profileField -> delete ( ) ; } else { $ included [ ] = $ profileField -> MemberField ; } } foreach ( $ fields as $ name => $ field ) { if ( ! in_array ( $ name , $ included ) ) { $ profileField = new MemberProfileField ( ) ; $ profileField -> MemberField = $ name ; if ( isset ( self :: $ profile_field_defaults [ $ name ] ) ) { $ profileField -> update ( self :: $ profile_field_defaults [ $ name ] ) ; } $ list -> add ( $ profileField ) ; } } return $ list ; }
Returns a list of profile field objects after synchronising them with the
Member form fields.

@return HasManyList|UnsavedRelationList Fields()
Returns a list of profile field objects after synchronising them with the Member form fields .