Member extension updateCMSFields doesn't show new fields

Silverstripe Version: 4.9

Question:

So I’ve been struggling with this at every start of new projects, I extend the Member class, I declare the extension of Members in the config.yml, the new fields are created in the database so everything up to there works fine. Though when I try to see the new fields in the admin area, they don’t show up despite following the exact code that is meant to make the fields appear. So what am I missing?

Here is the MemberExtension.php, fields are created but don’t show up in the admin area, I tried with addFieldsToTab, push, one field, an array of fields, Root.Extensions instead of Root.Main, nothing works, I did several Dev Build with Flush all, still nothing

I also tried with updateMemberFormFields($fields) and push, it doesn’t work either

<?php
use SilverStripe\Security\Permission;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;


class MemberExtension extends DataExtension 
{
       
    private static $db = [
        'Country' => 'Varchar(64)'
    ]; 

    public function updateMemberFormFields($fields)
    {
        Debug::show($fields);
        $fields->push(TextField::create('Country','Country'));
    }

    /*public function updateCMSFields($fields) 
    {
        Debug::show($fields);
        $fields->addFieldToTab('Root.Main', TextField::create('Country','Country'));
    }*/

}

It looks like you just missed the return statement.

public function updateCMSFields($fields)  
    {
            $fields->addFieldToTab('Root.Main', TextField::create('Country','Country'));
            return $fields;
    }
1 Like

So what happened is that there’s the SSviewer cache, and I simply had to flush it by adding ?flush=1 to the end of the admin URL and that what is.

Thanks for the support!

Sorry I was wrong, there is no return value in updateCMSFields (DataExtension) only in getCMSFields (DataObject).
So as you said it was just a caching problem.

https://api.silverstripe.org/4/SilverStripe/ORM/DataExtension.html#method_updateCMSFields

https://api.silverstripe.org/4/SilverStripe/ORM/DataObject.html#method_getCMSFields

1 Like

I have a lot of caching issues, I can’t get much of it to be cleared. I flush from the SSH console which is fine for most cases but I can’t flush=1 the admin area from the browser, it’s triggering an .htaccess access denied. I could chmod the .htaccess but not sure that’s recommend.