How to change submit button name in HAML? - html

I am new to Haml and have a form with two submit buttons. To differentiate and handle them in the Controller every single button needs a name.
An example from HAML:
= program_form.submit I18n.t('texts.6OA')
appears in HTML as:
<input type="submit" name="commit" value="Save Template">
but I want something like this:
<input type="submit" name="Button2" value="Save Template">
Any hints?

Have you tried this?
program_form.submit I18n.t('texts.60A'), name: 'Button2'

Related

What happens if we use mulptile button tags HTML with type as submit

I'm developing MVC application where I want to use button tags as it is the best tag as far as I know.
Can I use multiple HTML Button tags with <button type="submit">...</button>.
If you use more than one type=submit, all send the same parent form, but you can put differents submit buttons in differentes forms in the same page.
Both buttons will call submit action, example:
<form>
<input required type="text">
<button type="submit">submit</button>
<button type="submit">submit</button>
</form>
If u will not use any type, submit action will be called to, example:
<form>
<input required type="text">
<button>submit</button>
<button>submit</button>
</form>
If button will have type 'button' then submit action will not be called, example:
<form>
<input required type="text">
<button type="submit">submit</button>
<button>submit</button>
<button type="button">not</button>
</form>
You can use multiple button tags with type="submit" in a single form tag, only if you want that form is submitted after clicking on that button. And you can differ between those buttons by giving different names to them.

Submit Button not working - could be broken code?

Need help to get my form working. I am creating it for a website as a small school project.
Below is the code to the submit button. Am I missing something? (I can place the whole code if needed):
<form>
<!-- END_ITEMS -->
<input type="hidden" name="EParam" value="FzpUCZwnDno=" />
<div class="outside_container">
<input type="button" onclick="Vromansys.FormBuilder.showPreview()" value="Submit Form" class="submit_button" id="FSsubmit" />
</div>
</form>
Did you try input type="submit" ... instead of "button"? It should work with "submit" when using "form".
Best regards,
Dino

Google Material Icon In a HTML input?

I want an icon to go into an input submit button. I've tried the following, but it doesn't work. Any advice?
<input type="submit" name="submit" value="Submit" />
I wanna put the following in:
<i class="material-icons">star_rate</i>
There are various ways this can be done but according to your code just use
<button type="submit" name="submit"><i class="material-icons">star_rate</i></button>

How can I make an html button that passes a parameter?

I want a html button with parameter functionality.
new/?sorting=desc is the url that it should link to. But when I try, the parameter is not passed. How should it be done? I tried both the methods below but none worked.
<FORM METHOD="GET" ACTION="./?sorting=desc">
<INPUT TYPE="submit" VALUE="Äldst först">
</FORM>
I want buttons that behave like these links:
Äldst först
Nyast först
If you want something to act as a link, then you should use a link.
That said:
When you submit a GET form, the query string is removed from the action and a new one is generated from the data in the form.
You need to store the data in hidden inputs.
<form action="/social/tracking/new/">
<input type="hidden"
name="sorting"
value="desc">
<input type="submit"
value="Nyast först">
</form>
<form action="/social/tracking/new/">
<input type="hidden"
name="sorting"
value="asc">
<input type="submit"
value="Sort the other way">
</form>
If you are using jQuery, you can use the code below.
This will fill a hidden input with the correct value when you click on one of the submit buttons.
<form method="get" action="./">
<input type="hidden" name="sorting" id="sorting" value="" />
<input type="submit" value="Äldst först" id="sort_desc" />
<input type="submit" value="Nyast först" id="sort_asc" />
</form>
<script>
$('#sort_desc').click(function(){
$('#sorting').val('desc');
});
$('#sort_asc').click(function(){
$('#sorting').val('asc');
});
</script>
I think its not possible. A form is used to send data (mostly) via POST or GET. Your goal is to open a specific URL. I would create a standard and would style it like a button. Whats the reason you want to use a button?

Html input value

A simple html question i would like to make form that shows a different value to the one that it posts.
<form action="" method="post">
<input type="submit" name="action" value="Buy"/>
</form>
for example shows a button with Buy written on it and Buy is also posted. I would like it to show Buy, but I would like it submit a differnet value.
In theory you can:
<button type="submit" name="action" value="a differnet value">Buy</button>
In practise, we have to operate on a WWW that includes Internet Explorer.
You would probably be better off encoding the data into the name attribute and checking that.
probably the easiest way to do it is to attach an event to the form submission to change the value for that input button. You could probably also put an onclick for the submit button itself.
<form action="" method="post">
<input type="submit" name="action" value="Buy" onclick="this.value='some value';"/>
</form>
The button within form is only for checking if the form is submitted or not. You don't need to get the value of the button. Simply write html code:
<form action="smth.php" method="post">
<input type="submit" name="action" value="Buy"/>
</form>
And smth.php will look like that
if(isset($_GET['action']))
{
...
do smth
...
}