Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Prefill Add Form with data from endpoint #8229

@alexander-schranz

Description

@alexander-schranz

Problem description

After some discussion with a developer from our partner Adesso I think it should be easier in Sulu to prefill a Add Form with data a PHP endpoint for new resource endpoint.

Proposed solution

I could think by something like this would be awesome:

sulu_admin:
    resources:
        events:
            routes:
                list: app.events
                detail: app.event
+               prefill: app.event_prefill
class EventController {
    #[Route('/admin/api/events/prefill', name: 'app.event_prefill']
    public function prefillAction(): Response
    {
       return new JSONResponse(['someField' => 'somePrefilledValue']);
    }
}

I think it requires some adjustments to add prefill if !id is defined:

The prefill endpoint can return a JSON which will prefill the form store if the form is in add and not edit mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureNew functionality not yet included in Sulu

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions