Megabit / Blazorise

Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Tailwind, Bulma, AntDesign, and Material.
https://blazorise.com/
Other
3.32k stars 535 forks source link

[Bug]: Form inputs do not have a name #5592

Closed mrpmorris closed 5 months ago

mrpmorris commented 5 months ago

Blazorise Version

1.5.2

What Blazorise provider are you running on?

Bootstrap5

Link to minimal reproduction or a simple code snippet

N/A

Steps to reproduce

Create a page with form binding to a model. Use the Blazor and also

What is expected?

The generated html should have a name, just as InputText does.

What is actually happening?

Blazor InputText adds a name attribute to InputText etc, this allows Blazor SSR

binding.

Blazorise TextEdit does not do this, so the built in form binding does not work

<InputText @bind-Value=@Model.Account/> <input aria-invalid="true" name="Model.Account" class="invalid" value="asd">

<TextEdit @bind-Text=@Model.Account>

What browsers do you see the problem on?

Microsoft Edge

Any additional comments?

N/A

David-Moreira commented 5 months ago

I have mixed thoughts about this. Blazorise components have been developed to work with interactivity, so the standard Blazor Server and Blazor Webassembly.

Now Blazor SSR, specifically the mode without interactivity, let's call it static mode. might indeed be supported by Blazor standard components since they can render just enough html structure to be compatible.

However having Blazorise be static mode compatible might not be so easy as to just add a name attribute for instance, since some of the components are made a little more complex, with conditional rendering, with interactivity, with js calls, etc... which does require the "blazor engine" to be running.

So our stance so far as been that we do not support Blazor SSR static mode. So if we were to do something about this, we would have to look into every component, at least the input based ones, and be sure they are compatible just enough with Blazor static mode.

But since you're opening this issue specifically, how has your experience been with SSR (static mode) + Blazorise? Seems unlikely this would be the only issue stemming from this usage.

stsrki commented 5 months ago

I had a chat with @mrpmorris over Discord. This change is only needed for the input components. When inputs are binded to a model( @bind-* ), we need to provide a name attribute. This name attribute is required for the <form> post to work correctly.

Our idea is to reuse what we already have, a FieldIdentifier populated by the ValueExpression parameter. In theory, this should work. If the user wants, they can still override the name by defining it manually, as we already support attribute splatting.

David-Moreira commented 5 months ago

Fine, if that's the only change required and they start working sufficiently in static mode. I would have thought it would be more stuff + possible rendering issues.