This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

garhy.ahmed18512
garhy.ahmed18512

Hi I have a dropdown in fiedls.yaml it have 2 options, and on edit page it always showing "option A" as the selected on page load even if it's option2 in DB. type: label: 'app.plans::lang.plans.plan_type' oc.commentPosition: '' options: 1: 'A Plan' 2: 'B Plan' span: auto type: dropdown

how can I make the dropdown selectd option based on DB record on edit page load?

manuel.bua
manuel.bua

I'm also stuck with this: i've the getXYZOptions and getXYZAttribute methods in the model, but the edit page still show the first dropdown value.

manuel.bua
manuel.bua

Ah! I think i'm seeing the "problem" because i followed others code to have list columns display the attribute value instead of the key. To fix this, just set another field name in your columns.yaml such as {field}List and add another method to your model, such as get{field}ListAttribute for this specific case, here is mine:

    public function getTypeAttribute()
    {
        $key = array_get($this->attributes, 'type');
        return $key;
    }

    public function getTypeListAttribute()
    {
        $key = array_get($this->attributes, 'type');
        return array_get($this->getTypeOptions(), $key);
    }
manuel.bua
manuel.bua

..but i've yet to find a way to fix the sort thing if the column is sortable..

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.