Skip to content

MatBlazor.MatTextField requires a value for the 'ValueExpression' parameter. [1.5.3] #184

@djinnet

Description

@djinnet

In the newest update 1.5.3, I got this error "MatBlazor.MatTextField requires a value for the 'ValueExpression' parameter. Normally this is provided automatically when using 'bind-Value'."
The bug show up whenever an component are using textfield.

The bug should only show if MatTextField do not contain an value.

I am using basic authorizeView with EditForm in my code, and as you can see, MatTextField do have bind-values which means they contains values, so I am guessing the cause must be related to ValueExpression in the BaseMatInputComponent. Because the error message only show up if ValueExpression is null.

The code is working fine in 1.5.2 update.

/@ Template Admin authorize blazor code. The AdminObject contains name String, startTime DateTime, endTime DateTime. Save is an function that saved into an data source such as database with Entity framework. @/
<AuthorizeView Roles="Admin" Context="AuthContext">
    <Authorized>
	 <EditForm Model="AdminObject" OnValidSubmit="@(async () => await Save())">
		 <div class="container-fluid">
			<div class="row">
				<DataAnnotationsValidator />
				<ValidationSummary />
			</div>

			<div class="row">
				<div class="form-group">
					<div class="col-md-12">
						<label for="Name" class="control-label">Name</label>
						<MatTextField @bind-Value="AdminObject.Name" Label="Name" ></MatTextField>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-md-6">
					<label asp-for="Starttime" class="control-label">Start time</label>
					<MatDatePicker @bind-Value="AdminObject.startTime"></MatDatePicker>
					<MatButton OnClick="@(_ =>{AdminObject.startTime = null; this.StateHasChanged();})">Empty</MatButton>
				</div>

				<div class="col-md-6 ml-auto">
					<label asp-for="Endtime" class="control-label">End time</label>
					<MatDatePicker @bind-Value="AdminObject.endTime"></MatDatePicker>
					<MatButton OnClick="@(_ =>{AdminObject.endTime = null; this.StateHasChanged();})">Empty</MatButton>
				</div>
			</div>
			<button type="submit" class="btn btn-block btn-info">Save</button>
		</div>
	 </EditForm>
	</Authorized>
    <NotAuthorized>
        You do not have Admin Permission.
    </NotAuthorized>
</AuthorizeView>

I hope someone can find an fix for that bug, because it's currently breaking a lot of components.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions