Codeigniter 4 form action path - forms

sorry for the very noob question. I have a page : www.example.com/edit/3 with form inside.
<form class="" action="" method="post">
Usually my form action I will specify something like add, register, etc. In this case, I am not sure how do I specify it. Currently it is working when I save it if I leave it blank without specifying anything. But I am not sure is this the right way to do it.
Controller
public function edit_game(){}
Routes
$routes->match(['get', 'post'], 'account/edit_game/(:num)', 'Addgame::edit_game/$1');
Can anyone advise?

action="" is the URI to which send the form data, aka the controller where you treat the received data. If not specified, it will be the same page as the one you are currently on.
What you can do:
<form method="post">
</form>
<form method="post" action=""> <!-- same as previous -->
</form>
<form method="post" action="/some/page">
</form>
In the last example, note the leading /, it means it is according to the site root. If you forget it, it will be relative to the current URI.
Exemple, if the page containing the <form> is http://example.com/edit/3:
action="/some/page" will redirect to http://example.com/some/page.
action="some/page" will redirect to http://example.com/edit/some/page

Related

is there any way to send METHOD value in <a> tag

when I send edit request to edit() using <a> it's working because of 'GET', but for Delete, I have to send a request for Delete Method also, How I can send it without using the form like edit
Edit
<form action="{{url('/auctions',$auction->id)}}" method="POST">
#csrf
#method('DELETE')
<input type="submit" class="btn btn-danger"
value="Delete">
</form>
I just want to know that we can send METHOD value by <a> Or Not
Clicks on links via link are always GET requests and cannot be anything else.

Display multiple adminForm's in joomla

When creating a custom view in joomla with multiple forms, there is a conflict because each form has the id="adminForm" name="adminForm".
Renaming the form causes incompatibility with joomla.
How can I display multiple adminForm's on a single view?
Restructure the form elements into a single page-encompassing form
and remove the &task=controller.task portion from the form action
URL, e.g.
<form
action="<?php echo JRoute::_(''); ?>"
name="adminForm" id="adminForm" class="form-validate"
method="post" enctype="multipart/form-data">
On each submit button use the joomla method: onclick="Joomla.submitbutton('controller.task')" e.g.
<button type="submit"
onclick="Joomla.submitbutton('group.join')">Join</button>
Joomla will automatically update a hidden field with the name="task" and value="controller.task" which will get submitted with the form.
You need to have this element in your form for it to work, e.g.
<input type="hidden" name="task" value="" />
</form>

post form to an iframe on another form (is it possible)

I'm using ASP.NET web forms and i need to post data to an iframe, the problem is that in web forms I have the main form tag(form1), so i need another form tag(form2), to post data to the iframe that is in the main form1.
Basically i have this:
<form method="post" id="form2" action="http://localhost:58903/WebForm1.aspx" target="webApp">
<input type="hidden" name="ValidationUserName" value="david" />
<input type="hidden" name="ValidationTokenId" value="13123132132" />
<button type="submit">Send info to inner iframe</button>
</form>
<form id="form1" runat="server">
<iframe id="webApp" name="webApp" src="http://localhost:58903/WebForm1.aspx" style="width: 800px; height: 800px;"></iframe>
</form>
With this approach in open a new tab, if i put the iframe outside it works ok, but if i do this the layout is changed and i don't want this.
Is this possible?
If all the forms are in the same domain you should not work with iframes.
What exactly are you trying to get here? didn't realize completely
Done it, it was missing the "name" attribute in the <form> tags.

Anyone know how to make an entire form disappear on a jsp page?

<H1 align="center">ID Lookup</H1>
<FORM ACTION="index.jsp" METHOD="POST">
<H3 ALIGN="center">Please enter your User ID:</H3>
<INPUT TYPE="TEXT" NAME="userIDTextBox">
<br>
<br>
<INPUT TYPE="SUBMIT" value="Submit">
<%
String userID = request.getParameter("userIDTextBox");
%>
</FORM>
I'm a beginner and this is my form on my jsp page. What I want to do is have the form disappear after submitting. Can anyone help me please? Or give some tips?
Give your form an ID, then use a javascript command to get your form element and set its visibility.
var myform = document.getElementById('myForm');
myform.style.visibility="hidden";
Now you just need to handle a javascript event and run that.
After Reading your requirement all I understand is you are trying to read parameter "userIDTextBox" from one page and need to display the value to some other page. And You are trying to achieve the same in one page.
Rather have two separate pages..
First with Form and required text field
Other to display the value
Define servlet and servlet-mapping configuration in web.xml
That is the valid way to do it. Hope it may help

Magento: How to redirect on form submit

I'm using Magento CE 1.7.
I created a CMS page to add 'Terms Of Use' to it and at the bottom of the page I added a simple "Accept Terms" submit form to have the customers agree to the terms before they can access the page I want them to access. Here's the code.
<form action="url-to-go-to.html" method="GET" onsubmit="return checkCheckBox(this)">
I accept: <input type="checkbox" value="0" name="agree">
<input type="submit" value="Continue">
<input type="button" value="Exit" onclick="document.location.href='BACKTOWHAT.html';">
</form>
<script type="text/javascript">
<!--
function checkCheckBox(f){
if (f.agree.checked == false )
{
alert("Please tick the box to continue");
return false;
} else
return true;
}
-->
</script>
The only problem I have is that in I can only get it to work by entering the URL to the page I want them to be redirected to. i.e.
<form action="domainname.com/shop.html"> <!-- store section to go to -->
/* and the same goes for */
onclick="document.location.href='domainname.com';"> <!-- back to storefront -->
I wanted to use something else rather than the URL but I'm not sure how to do it. I thought using something like this would work.
<form action="<?php echo $this->_redirect('shop.html'); ?>" method=.... >
but it didn't.
I believe if this has been within a .phtml file it would've worked but I'm working with a simple CMS page and I know magento functions work in CMS pages but I don't know a function that would work for this purpose.
Ok, I figured it out after testing a bit more. (I'm still learning how to code)
It's quite simple, the form action should be like this instead.
<form action="{{store direct_url='shop.html'}}" method=..... >
and to redirect back to the store front on "exit" this is what worked.
onclick="document.location.href='{{store direct_url=' '}}
This worked perfectly. hope it helps others.