DmitryEfimenko / TwitterBootstrapMvc

Fluent implementation of ASP.NET-MVC HTML helpers for Twitter Bootstrap.
Apache License 2.0
224 stars 79 forks source link

Submit Button #44

Closed leeenglestone closed 10 years ago

leeenglestone commented 10 years ago

Could do with a submit button helper method that will simply return the html <input type="submit" value="Save" class="btn" />

and when pressed will obviously just submit any form it's on.

... @Html.Bootstrap().ControlGroup().TextBoxFor(x=>x.Name) @Html.Bootstrap().ControlGroup().SubmitButton() // Something like this ...

-- Lee

DmitryEfimenko commented 10 years ago

I suppose this could be done. However I'd like to point out that Twitter Bootstrap 2 has a component form actions that you can see under forms (though it seems that it will be dropped in v3 ). It achieves similar effect and BMVC supports it with the following syntax:

using (Html.Bootstrap().Begin(new FormActions()))
{
    @Html.Bootstrap().SubmitButton()
}

Alternatively you could use CustomControls with the following syntax:

@Html.Bootstrap().ControlGroup().CustomControls(Html.Bootstrap().SubmitButton())

Given these options do you still see a need in such helper?

leeenglestone commented 10 years ago

So long as I can do this it is fine, cheers. Feel free to close the issue, if this is the case. Thanks.

@Html.Bootstrap().ControlGroup().CustomControls(Html.Bootstrap().SubmitButton())

-- Lee

DmitryEfimenko commented 10 years ago

I'm gonna leave it open for now. I kind of like it since it looks cleaner. The problem that I have with it is that it lucks flexibility. Usually submit button goes together with Cancel button. Would be nice if we got some more opinions...

leeenglestone commented 10 years ago

Not sure where a cancel button would fit in other than just emitting a plain old button.

The reason I specifically suggested a SubmitButton was to emit this inside a ControlGroup.. Obviously the attributes need to be settable (value, class etc etc)

<input type="submit" value="Save" class="btn" />

I.e. a button that when pressed would submit whatever form it is on.

But if there is already a way to do this like you say (albeit less direct) then i'm happy.

@Html.Bootstrap().ControlGroup().CustomControls(Html.Bootstrap().SubmitButton())

-- Lee

DmitryEfimenko commented 10 years ago

So far I decided to stick with the CustomControls for this. If I get more request for this feature, I'll implement.