Skip to content

Set default data #58

@koertho

Description

@koertho

Hi, I struggled a little so set (dynamic) default data for a group widget.

Background: I have a bundle where classes define types. These types can define default data (which should be used in a group widget). When I create a new element in the backend and the type is selected, the default data should be set. After a lot of try&error I end up with following solution:

// parent group field onload callback
$request->request->set("widget-group__myField", 1);
$typeModel->myField = serialize([1 => $type->getDefaults()]);
$typeModel->save();

So I have a working solution, but it's not a very nice one. Is there a better way I did not notice?
I also tried load_callbacks, setting default values (dca) for a child group field, using the group field registry and so one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions