You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a form that I call to update a record and it turns out that the record cannot be modified, because when assigning the model to the html form, the fields that are not in the input elements are not linked, I have tried to put the elements but on they are linked.
MODEL:
``
public class WebLink : IWebLink
{
public Guid WebLinkId { get; set; }
[StringLength(128, ErrorMessage = "El titulo del enlace no puede superar los 128 caracteres.")]
[Required(ErrorMessage = "Tiene que especificar el titulo del enlace.")]
public string? Title { get; set; }
public bool Enabled { get; set; }
[StringLength(512, ErrorMessage = "El enlace no puede superar los 512 caracteres.")]
[Required(ErrorMessage = "Tiene que especificar el enlace.")]
[RegularExpression(@"^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$", ErrorMessage = "El enlace no es válido.")]
public string? Hyperlink { get; set; }
[Timestamp] public byte[]? RowVersion { get; set; }
public DateTimeOffset UpdatedAt { get; set; }
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a form that I call to update a record and it turns out that the record cannot be modified, because when assigning the model to the html form, the fields that are not in the input elements are not linked, I have tried to put the elements but on they are linked.
MODEL:
``
public class WebLink : IWebLink
{
public Guid WebLinkId { get; set; }
}
``
CODE:
[SupplyParameterFromForm(FormName = "webLinkForm")] public Models.WebLink WebLinkModel { get; set; } = new();
HTML:
<EditForm Enhance Model="WebLinkModel" OnValidSubmit="SaveWebLinkAsync" FormName="webLinkForm"> <input type="hidden" @bind="WebLinkModel.WebLinkId"/> <input type="hidden" @bind="WebLinkModel.RowVersion"/> <div class="row py-2 border-bottom border-primary"> <div class="col-md-6"> <ButtonSubmit class="btn btn-primary me-1">Guardar</ButtonSubmit> <ButtonRef class="btn btn-secondary" HRef="\Manage\WebLinks">Volver</ButtonRef> </div> </div> <div class="p-2"> <DataAnnotationsValidator/> <ValidationSummary/> <div class="mb-3"> <label class="form-label">Titulo:</label> <InputText class="form-control" @bind-Value="@WebLinkModel.Title" autofocus/> <ValidationMessage For="@(() => WebLinkModel.Title)"/> </div> <div class="mb-3"> <label class="form-label">Hypervinculo:</label> <InputText class="form-control" @bind-Value="@WebLinkModel.Hyperlink"/> <ValidationMessage For="@(() => WebLinkModel.Hyperlink)"/> </div> <div class="mb-3"> <div class="form-check"> <InputCheckbox class="form-check-input" @bind-Value="@WebLinkModel.Enabled"/> <label class="form-check-label">Activo</label> </div> <ValidationMessage For="@(() => WebLinkModel.Enabled)"/> </div> </div> </EditForm>
Beta Was this translation helpful? Give feedback.
All reactions