i have a <form> in the first view and </form> in the last view.
Looking at the DOM i can see that form tag is being closed in the final of the first view and i am only getting the input data of the first view.
enter image description here
I´ve tried putting <form> as first and last tags of my frontend code but then the request don´t work.
PD. Sorry for my english.
I am working with laravel.
Thanks.
All tags may contains another tags but never contain a lot of codes from tag. This is not sense.
If you want to form for multiple view, please use form in layout file not in 1-2-3 files
Related
I have only one php file called index.php. I have created there a form with one input text element and one input submit element. When I click on submit I want to deal with the value from the input element in the function that is in the same file, namely index.php. So my question is what to write into action attribute of the form element, if i will write index.php it doesnt work properly because then I get to the dashboard of wordpress. (I am trying to create a wp plugin).
-I am PHP and also Wordpress beginner-
I think the quickest way is just not to set any action on the form html tag. That way it will just POST/GET data to the same page from where you're calling it. Does this make it for you?
I am working on an application that displays a linechart from database records.
The user views the graphic in a html page and can change the parameters to view the chart he is interested in by selecting them from a select box.
Behind the html page there is php page that does the query to the database and converts the result into json format to be used for the graphic in the html page.
Right now I am trying to post the values from the select box (with the parameters the user selected) into the php page, but I don't want to see the php afterward, instead I want the html page to be refreshed to show the new graphic with the selected values.
To post the values to php I am using something like this:
<form action="index.php" target="_blank" method="post">
<select name="Tasel" onchange="this.form.submit()">
<option value="3">Tuloslaskelma</option>
<option value="2">Tasevastattava</option>
<option value="1">Tasevastaava</option>
</select>
It posts the values ok, but now I don't know how to reload the html with the new graphic at the same time. I would appreciate some suggestions on what is the best way to go here. I have read several suggestions about using Ajax, but haven't really found the way to make it work. Thanks in advance!!!
Using the redirect-after-post pattern is a cleaner solution to the problem you face.
A more advanced description can be found here.
Another point is that you need to take care about the response headers sent by your webserver alongside the image response. If there is something like caching involved it might cause the old picture to be displayed.
You need to learn a bit more about JavaScript (or jQuery if you prefer) if you want to use Ajax.
Otherwise, you can simply put a redirect after the form process (in index.php) is complete.
index.php
<?php
// Form processor here
// Make sure nothing is outputted to the browser
header( 'Location: ' . $_SERVER['HTTP_REFERER'] );
exit();
I am new to html, I would be really glad if you can help me with this.
I have a web page where there is a list and some other text inputs and buttons. This option list can be populated by clicking the "add" button in the page, this add button is to direct to another page and in that page there are some chekboxes, those which are checked are loaded back to the main page,(where I have the list) .
At the end data in the main page needs to be loaded to the database, (what is in the list and in the text inputs).
Since I'm new I just know little about php and html, I thought I should have a form within a another form(form to "add items", form to load to the database) and it is not possible in html. Can anyone suggest the best way to do this? Do I need to use javascript?
Why can't the extra inputs (the ones that would be in the second form) be part of the first form? I think the question will become clearer if you post a sample form so we can see the relationship between the two forms.
But overall, since you're ultimately only submitting one form, then maybe all the inputs belong together. If what you're calling the second form isn't supposed to be visible right away, you can still have it be part of the same form, but only reveal it when needed.
Again, some sample data would help to understand the exact context of your question.
in php if you use input name="somename[]"
for a number of input elems
you will get an array in $_POST['somename'] and access all the values.
I think what you're after - if I understand you correctly - is ajax. Ajax allows you to asynchronously send data to/from another script without leaving the current page. This is accomplished using JavaScript. In your case I think what you need to do is set an onclick event in JavaScript to a button:
<input type="button" onclick="javascriptFunction()">
You can read more about ajax here:
http://www.tizag.com/ajaxTutorial/ajaxform.php
I have a form that I generate new input fields to with javascript and the generated fields won't post.
I have made a demo which I stripped the database etc. because it might not have been secure (for injections) which var_dumps POST
http://resk.latvalashop.com/test.php
Try to fill in everything and press a couple times the "+" button to add a couple of rows, fill them and then press "Tallenna" which will POST the form.
the problem is the floating element to right of the main element, the first fields are not generated by javascript and POST as they should, but if you press the "+" and try to post from the newly created forms nothing will be POSTed.
Any help appriciated!
The generated input elemnts are not contained inside of an <form> element, so they are not able to be posted. You should push your <form action="result.php" ... > higher up in the DOM hierarchy.
I think your problem is in your HTML.
The level where you open your <form> element (3 <div>'s deep) isn't the same as where you close it (2 <div>'s deep). That will probably fix it.
You have to wrap those with <form></form> tags.
With symfony, I use widgets to display a form.
Once everything is filled and validated, I land on a "review" page where all the information the user entered appears as text (<span>). To do this, I created a formatter (instead of table, I called it "review"). The formatter spits out <span> instead of <input>
It works great for basic inputs, but when it comes to Choices, or Dates, it's not working super great... I feel there is another way to have a review page without having to write a whole page just for this?
Any ideas?
Unfortunately, I find it sad that there is no concept of displaying the data already posted on a page with Symfony.
Using getValues() to recreate the whole UI with the same exact design with the exception of using <span> instead of <input> doesn't keep the code DRY at all...
I decided to create a formatter as I mentioned in my question with adding some "if" clause to make sure everything displays correctly.
You could adjust your formatter to handle other types of form elements, or you could try using some type of lightbox before the form is submitted. But in the end, I'd just go ahead and write that extra page. Everything your trying to do sounds so much more complicated than just a separate page.
I find this approach such a hassle. Why don't you pass the result of $form->getValues() to the view and output them however you want in the template?