BlazorDynamicForm
BlazorDynamicForm copied to clipboard
InputText requires a value for the 'ValueExpression' parameter
Hi
I was just testing this library, and getting the following error:
Unhandled exception rendering component: Microsoft.AspNetCore.Components.Forms.InputText requires a value for the 'ValueExpression' parameter. Normally this is provided automatically when using 'bind-Value'. System.InvalidOperationException: Microsoft.AspNetCore.Components.Forms.InputText requires a value for the 'ValueExpression' parameter. Normally this is provided automatically when using 'bind-Value'.
It creates the label, but fails to create InputText.
Code:
<div>
@if (definition != null && formModel != null)
{
<DynamicForm DataDefinition="@definition" DataObject="@formModel" OnValidSubmit="@OnSubmit">
<ValidationMessageTemplate Context="error">
@error
</ValidationMessageTemplate>
<FieldTemplate Context="template">
<div class="row mb-3">
<label for="@template.PropertyInfo.Name" class="col-sm-2 col-form-label">@template.PropertyInfo.DisplayName</label>
<div class="has-validation col-sm-10">
<div class="col">
@template.DynamicComponent
</div>
@if (!template.IsValid)
{
<div class="invalid-feedback d-block">
@template.ValidationComponent
</div>
}
</div>
</div>
</FieldTemplate>
<SubmitTemplate>
<div class="col-12">
<button type="submit" class="btn btn-primary">Save</button>
</div>
</SubmitTemplate>
</DynamicForm>
}
</div>
@code {
private ModuleNodeDefinition definition;
private dynamic formModel = null;
protected override void OnInitialized()
{
definition = new()
{
PropertyDefinitions = new List<ModuleNodePropertyDefinition>
{
new() { Name = "Note", DisplayName = "Note", DataType = DataType.Text, DefaultValue = default(string) }
}
};
var json = Newtonsoft.Json.JsonConvert.SerializeObject(new { Note = "testing" });
formModel = Newtonsoft.Json.JsonConvert.DeserializeObject<ExpandoObject>(json, new Newtonsoft.Json.Converters.ExpandoObjectConverter());
}
public Task OnSubmit()
{
return Task.CompletedTask;
}
}
This seems to occur when using builder.Services.AddBlazorDynamicForm().DefaultDynamicForm();
This seems to occur when using builder.Services.AddBlazorDynamicForm().DefaultDynamicForm();
@petarvu looking in too it, by the way using the class directly creates errors?