Prompt file imported from Develop4Us-Company/dotnet-template (
.github/prompts/create-form-page.prompt.md). Copyright stays with the author.
Create Form Page
Create a form (registration/edit) page for an entity that already has a backend and Refit client implementation.
Required Information
You MUST ask the user for:
- Entity name (e.g.,
Product,Country) - Module name (e.g.,
General,Finance) - Form fields (labels, types, validations, max lengths)
- Whether the entity has FK fields requiring dropdown selectors
- Whether the entity has nested/child items (like City → Neighborhoods)
Instructions
Follow the form page section of the frontend-crud skill:
- Create the form page at
src/AppProject.Web.<Module>/Pages/<EntityName>FormPage.razor - The page must:
- Use
@attribute [Authorize] - Inherit from
ModelFormPage<<EntityName>> - Use
ModelFormControlwithOnSaveandOnCancelhandlers - Use
FieldsetControlfor grouping fields - Display the ID as read-only text
- Use
RadzenFormFieldwith appropriate Radzen input components - Use validators:
RadzenRequiredValidator,RadzenLengthValidator,RadzenCustomValidator - Accept
[Parameter] public Guid? Idfor edit mode - Load existing data in
OnInitializedAsyncifIdhas value - Handle Post (new) vs Put (edit) in
OnSaveAsync - Close dialog with
CloseDialogAsyncafter successful save
- Use
For FK Selection Fields
Use dropdown components inheriting from DropDownDataGridControl:
<ParentSummaryDropDownDataGridControl @bind-Value=@this.Model.ParentEntityId />
<RadzenCustomValidator Component="ParentField"
Validator=@(() => this.Model.ParentEntityId != Guid.Empty)
Text=@StringResource.GetStringByKey("...Required") />
For Nested Child Items
Follow the CityFormPage.razor pattern:
- Add a
DataGridControlwithPreferAddOverNewfor child items - Open child form dialogs that return the child model
- Track changes in
ChangedChildRequestsandDeletedChildRequests
- Add resource keys for:
- Form title:
<Module>_<EntityName>FormPage_Title - Fieldset titles:
<Module>_<EntityName>FormPage_<Fieldset>Fieldset_Title - Field labels:
..._<Field>Field_Label - Validators:
..._<Field>Field_Required,..._<Field>Field_InvalidLength - ID field:
..._IdField_Text
- Form title:
Reference Implementations
- Simple form:
src/AppProject.Web.General/Pages/CountryFormPage.razor - Form with FK:
src/AppProject.Web.General/Pages/StateFormPage.razor - Form with nested items:
src/AppProject.Web.General/Pages/CityFormPage.razor - Child form dialog:
src/AppProject.Web.General/Pages/NeighborhoodFormPage.razor
