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

GlamCat
GlamCat

Hi all! Got a one question about updating data when using dependsOn option in field and filterFields function in my model.

That's what I have in my fields.yaml:

type:
    label: "Type"
    span: auto
    type: relation
    emptyOption: " "
    required: true

print_format: 
    label: "Print format"
    span: auto
    dependsOn: type

And that's in my model:

public function filterFields($fields, $context = null)
{
    if ($this->type->slug == 'print') {
        $fields->print_format->hidden = false;
    } else {
        $fields->print_format->hidden = true;
    }
}

Everything works fine when I save my model item and refresh the page, but when I select different choices in Type dropdown field I see just a loading circle near field but it doesn't hide/show as I expect from this example from documentation.

Any suggestions?

Last updated

Cpt.Meatball
Cpt.Meatball

Did you ever fix this?

Last updated

daftspunky
daftspunky

There is a working example of this in the Test plugin when you manage Countries.

Mohsin
Mohsin

I’m trying to make the reverse of this work i.e. when a dropdown field option is chosen the relation data must change. This is useful because I had a dropdown with different types -- restaurant, gas station, etc. and each of them have different kinds of facilities. Help would be appreciated.

chris.e.mcquilkin11830
chris.e.mcquilkin11830

Mohsin said:

I’m trying to make the reverse of this work i.e. when a dropdown field option is chosen the relation data must change. This is useful because I had a dropdown with different types -- restaurant, gas station, etc. and each of them have different kinds of facilities. Help would be appreciated.

im trying to get this to work too

walidh9326228
walidh9326228

There is an issue on github addressing the same problem.

https://github.com/octobercms/october/issues/4144

1-6 of 6

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