This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
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
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.
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
1-6 of 6