0
<form method="post" action="/edit">
    <form method="post" action="/add">
        <input type="submit" value="submit">
    </form>
<input type="submit" value="submit">
</form>

i have problem here.how to have form in one form ?

rails_noob
  • 311
  • 2
  • 5
  • 14

2 Answers2

2

Nested forms are not supported in HTML. See any of the standards, e.g., http://www.w3.org/TR/html5/forms.html#the-form-element. It's a flow content element without form element descendents.

tvanfosson
  • 524,688
  • 99
  • 697
  • 795
0

This isn't really as difficult as you're likely thinking it has to be. You can't nest tables. So, use the technology at your disposal. In my shop, we use a lot of PHP, and the common form pattern is to check if there's a id in a request variable. If so, it's an edit, else it's an add. Then, using the technology we have, PHP, we dynamically condition the action of the form.

Similarly, you could condition the form action via Javascript, .Net, Rails, etc. You could simply ignore the form altogether and use Javascript to submit it entirely. It's up to you....but the important thing is that you're not trying to nest the forms as that would break W3C conventions.

I'd recommend before really starting to tackle any sort of application design or anything dynamic, take a "timeout" from programming and make like a UI developer for a week or two. Do straight HTML and CSS, throw in some javascript, do some compliant cut-up and just eat sleep and breath w3 standards. I fought it tooth and nail for years until I got in a job where it was all I did, and it was like a light went off. The programming will make a ton more sense too, believe it or not.

bpeterson76
  • 12,918
  • 5
  • 49
  • 82