# button

**URL:** <https://discuss.rubyonrails.org/t/button/48828>\
**Category:** rubyonrails-talk\
**Created:** [January 25, 2010, 8:30am UTC](https://discuss.rubyonrails.org/t/button/48828 "2010-01-25T08:30:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [January 25, 2010, 8:30am UTC](https://discuss.rubyonrails.org/t/button/48828/1 "2010-01-25T08:30:27Z")

</div>

Hi &nbsp;&nbsp;&nbsp;I have \<button type="submit" class="class1"\>\<span\>Create \</span\>\</button\>

&nbsp;&nbsp;&nbsp;&nbsp;Could anybody say get the same above using railshelper I tried

f.submit "Create",:class =\> 'class1' But not correct

Thanks Tom

---

<div class="post-metadata">

**Author:** ![Colin\_Law1](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@Colin\_Law1](https://discuss.rubyonrails.org/u/Colin_Law1)\
**Post date:** [January 25, 2010, 10:10am UTC](https://discuss.rubyonrails.org/t/button/48828/2 "2010-01-25T10:10:14Z")

</div>

> Hi I have \<button type="submit" class="class1"\>\<span\>Create \</span\>\</button\>
> 
> Could anybody say get the same above using railshelper I tried
> 
> f.submit "Create",:class =\> 'class1' But not correct

What is not correct about it? What does it generate? If you get an error show us the code around it.

Colin

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [January 25, 2010, 12:18pm UTC](https://discuss.rubyonrails.org/t/button/48828/3 "2010-01-25T12:18:50Z")

</div>

Colin Law wrote:

> > Hi � I have \<button type="submit" class="class1"\>\<span\>Create \</span\>\</button\>

Not an error f.submit creates the html as \<input class="class1" id="model\_submit" name="commit" type="submit" value="Create" /\>

But what I need is exactly \<button type="submit" class="class1"\>\<span\>Create \</span\>\</button\>

&nbsp;&nbsp;&nbsp;&nbsp;If directly use this no problem But what I ould like to know an alternative in railshelper

Tom

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [January 25, 2010, 3:03pm UTC](https://discuss.rubyonrails.org/t/button/48828/4 "2010-01-25T15:03:19Z")

</div>

Tom Mac wrote:

> Colin Law wrote:
> 
> > > Hi � I have \<button type="submit" class="class1"\>\<span\>Create \</span\>\</button\>
> 
> Not an error f.submit creates the html as \<input class="class1" id="model\_submit" name="commit" type="submit" value="Create" /\>
> 
> But what I need is exactly \<button type="submit" class="class1"\>\<span\>Create \</span\>\</button\>
> 
> &nbsp;&nbsp;&nbsp;&nbsp;If directly use this no problem But what I ould like to know an alternative in railshelper
> 
> Tom

You also have button\_tag but this won't create an html \<button\> tag, it does though create a simple form wrapped around an input which means your backend gets a consistent result regardless of the browser (\<button\> is a bit inconsistent depending on the users browser).

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [January 25, 2010, 3:04pm UTC](https://discuss.rubyonrails.org/t/button/48828/5 "2010-01-25T15:04:29Z")

</div>

> You also have button\_tag but this won't create an html \<button\> tag, it does though create a simple form wrapped around an input which means your backend gets a consistent result regardless of the browser (\<button\> is a bit inconsistent depending on the users browser).

oops i meant button\_to .....

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [January 25, 2010, 10:25pm UTC](https://discuss.rubyonrails.org/t/button/48828/6 "2010-01-25T22:25:03Z")

</div>

Tom Mac wrote:

> Hi &nbsp;&nbsp;&nbsp;I have \<button type="submit" class="class1"\>\<span\>Create \</span\>\</button\>
> 
> &nbsp;&nbsp;&nbsp;&nbsp;Could anybody say get the same above using railshelper I tried
> 
> f.submit "Create",:class =\> 'class1' But not correct

Try content\_tag -- or just write the literal HTML.

> Thanks Tom

Best,

---

<div class="post-metadata">

**Author:** ![Chris\_Habgood](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@Chris\_Habgood](https://discuss.rubyonrails.org/u/Chris_Habgood)\
**Post date:** [January 26, 2010, 12:37am UTC](https://discuss.rubyonrails.org/t/button/48828/7 "2010-01-26T00:37:12Z")

</div>

Have you tried: :html=\>{:id =\> 'submit',:class=\>'calss1'}

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [January 26, 2010, 12:45am UTC](https://discuss.rubyonrails.org/t/button/48828/8 "2010-01-26T00:45:24Z")

</div>

Chris Habgood wrote:

> Have you tried: :html=\>{:id =\> 'submit',:class=\>'calss1'}

That won't do it. The solutions I provided are the only correct ones.

Best,

---

<div class="post-metadata">

**Author:** ![Chris\_Habgood](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@Chris\_Habgood](https://discuss.rubyonrails.org/u/Chris_Habgood)\
**Post date:** [January 26, 2010, 3:39am UTC](https://discuss.rubyonrails.org/t/button/48828/9 "2010-01-26T03:39:33Z")

</div>

works with my submit\_to\_remote.
