# Autofill Fields in fields.yaml

**URL:** <https://talk.octobercms.com/t/autofill-fields-in-fields-yaml/977>\
**Category:** Need Help\
**Created:** [February 1, 2023, 3:27pm UTC](https://talk.octobercms.com/t/autofill-fields-in-fields-yaml/977 "2023-02-01T15:27:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibrarartisan](https://talk.octobercms.com/user_avatar/talk.octobercms.com/ibrarartisan/32/475_2.png) [@ibrarartisan](https://talk.octobercms.com/u/ibrarartisan)\
**Post date:** [February 1, 2023, 3:27pm UTC](https://talk.octobercms.com/t/autofill-fields-in-fields-yaml/977/1 "2023-02-01T15:27:25Z")

</div>

Hello,

I am making a custom setting form for a plugin in the backend. I have render the form in controller index.htm and saving the form onSave event. however now i am lost how to populate the form entries from config/database table.

the database table is my\_clients\_setting.

the columns are:  
id (PK),  
status(booloean =\> switch)  
key(identifier =\> string)  
value(value of the form =\> string)

```auto
fields:
    status:
        label: ''
        span: full
        on: Disable
        off: Enable
        type: switch
    key:
        label: Key
        span: auto
        disabled: 1
        type: text
        value: 'Test'
    value:
        label: Value
        span: auto
        type: text

```

following is my controller

```auto
public $implement = [
        //'Backend\Behaviors\ListController',
        'Backend\Behaviors\FormController' ];

    public $listConfig = 'config_list.yaml';
    public $formConfig = 'config_form.yaml';

    public function __construct()
    {
        parent::__construct();
        BackendMenu::setContext('My.Clients', 'main-menu-clients', 'side-menu-client-settings');
    }

    public function index() {
        $this -> initForm($this);
        $this -> pageTitle = 'My Clients Settings';
    }

    public function onSave(){
        $saveSettings = new \My\Clients\Models\MyClientsSettings();
        $saveSettings->status = true;
        $saveSettings->key = 'key';
        $saveSettings->value = 'value';
        $saveSettings->save();
    }

```

i saw this article which is what i want to have but it is not very clear that how one can implement this in a custom controller/form

```auto
https://docs.octobercms.com/2.x/plugin/settings.html#settings-link-registration

```

Thank you in advance

---

<div class="post-metadata">

**Author:** ![daftspunk](https://talk.octobercms.com/user_avatar/talk.octobercms.com/daftspunk/32/4_2.png) [@daftspunk](https://talk.octobercms.com/u/daftspunk)\
**Post date:** [March 1, 2023, 1:30am UTC](https://talk.octobercms.com/t/autofill-fields-in-fields-yaml/977/2 "2023-03-01T01:30:29Z")

</div>

Try extending the form fields:

> **[Form Controller - October CMS - 3.x](https://docs.octobercms.com/3.x/extend/forms/form-controller.html#extending-form-fields)**
>
> Adds form management features to any backend page.

Something like this:

```auto
public function formExtendFields($form)
{
    $form->getField('myfield')?->value = 'default value';
}

```
