Zend_Form not submitting - php

I built a custom Zend_Form "myForm" and I passed it to my view with:
$this->view->form=new myForm();
Problem: form is not submitting (page doesn't reload/refresh).I thought something was wrong with the "form" tags,but I copyied the bottom code in another page (that is not a Zend environment) and is working.This is the source code:
<form enctype="multipart/form-data" method="post" action="">
<input type="text" name="title" id="title" value="" class="">
<textarea name="text" id="text" class=""></textarea>
<input type="text" name="allegati" id="allegati" value="" class="">
<input type="hidden" name="MAX_FILE_SIZE" value="2097152" id="MAX_FILE_SIZE">
<input type="file" name="file" id="file" class="media[]"></span>
<input type="submit" name="submit" id="submit" value="submit" class="">
</form>
SOLVED: As some of you guys suggested javascript is giving problems:
I had a js script overriding with:
$('form').submit();
Thanks
Luca

Form submitting issues are 99% related to javascript conflicts with the 'form' element or with a wrong defined 'form' tag.
Always check those above when encountering problems.
P.s. for the remaining 1% feel free to ask at Stack!
Best regards

Just a suggestion - try to rename your submit button to something but not "submit" (i.e name="mysubmitbutton").
I think the problem could be with expandos: http://ejohn.org/blog/deadly-expandos/. By default, a form element has a submit function. But, if you call any field inside your form with the name "submit" (like you do in your example), the form.submit will point to your input element and you'll not be able to submit your form.

Related

Can not pass the action get param to the PHP file

I have a smarty project, and in the .tpl file, there is a form:
<form method="get" action="{$smarty.server.PHP_SELF}?action=func1">
<input type="text" name="username"/>
<input type="submit">
</form>
there is a question, if the php file have many function for different action requests, so in the template if have many forms, I want to through the action for distinguish.
but in my practice, see upper code, I write like this, this can not delivery the action to my php file.
I want to write the action in the form action, because this can be more standard. so I don't want to write it in a hidden input. why write in the action can not pass into the php file?
You could use submit button with specified name and value:
<form method="get" action="{$smarty.server.PHP_SELF}">
<input type="text" name="username" />
<input type="submit" name="action" value="func1" />
</form>
and then you'll get a global variable $_POST['action'] with value func1. But the value will be showing on your button title, so I offer you to find forms only by submit name, for example name='submit_form1'.

how to get in url with value.html

This form submits url like that
http://www.website.com/page/search.php?search=demo&submit=Search
<form action="search.php?search=" method="GET" id="search-form">
<input id="search-text" name="search" type="text" maxlength="30" placeholder="type keyword"/>
<button type="submit" name="submit" value="Search" id="search-button">Search</button>
</form>
Where I want to post the form like that:
http://www.website.com/page/search/demo.html
How can I do this?
I know it is a small thing but help me..
Thanks
I am unclear what your question is.
If you mean that you want to be able to process the input client-side, that is not possible unless you override the behavior with javascript. For example with jQuery
$( "search-form" ).on( "submit", function( event ) {
// Do stuff here with the form data
event.preventDefault();
});
If you mean that you don't want .php to show up and want to hide the underlying server technology, then you can use something like Apache's mod_rewrite. But you probably don't want that in this case because .html implies that it's a page you visit (GET, not POST) rather than a script you submit variables to.
Save this code as form.html on your desktop then open it with your browser then add some values and click the button. Look at the url afterwards
<form method="get" action="#">
<input type="text" name="input1">
<input type="text" name="input2">
<input type="text" name="input3">
<input type="text" name="input4">
<button type="submit">Click me and look at the url</button>
</form>
After seeing your edited question, try this with the above steps( save on the desktop etc.etc)
<form method="post" onsubmit="this.action=window.location.href.replace('.html',inputurl )">
<input type="text" name="input1" onblur="inputurl='/'+this.value+'.html'">
<button type="submit">Click me and look at the url</button>
</form>

HTML/PHP : how can I have multiple form that send informations to the same page?

My problem is this :
I got 2 forms that are supposed to send different informations to the same page (via POST method). Each form has a submit button. However when I press any of the button, information from both forms are sent to the page.
Is it normal or is there something that I do wrong ?
I can already tell you without looking at your HTML.
You have to properly close the first form before opening the second. Easy mistake to make.
<form method="post" action="page.php">
<input type="text" name="something" />
<input type="submit" value="Submit" />
</form>
<form method="post" action="page.php">
<input type="text" name="somethingelse" />
<input type="submit" value="Submit" />
</form>

User input not showing in search form

I have a free form search that I moved from my main content to my header. Once I moved the form into the header the text inside of it stopped showing. The placeholder works but when you begin typing it is completely blank. The search and the functionality work perfectly, I just cannot see what I am typing. Any ideas?
<form class="search" action="/all-results/" method="get">
<fieldset>
<span class="text"><input name="searchProducts" value="All" type="hidden">
<input type="hidden" name="search_selection" value="all">
<input name="byString" id="s" type="text" value="" placeholder="<?php echo __('Search','Avada'); ?>" /></span>
</fieldset>
<form name="input" action="/all-results/" method="get">
<input type="submit" id="search_button" value="Search">
</form>
</form>
Your HTML is invalid. You can not nest a <form> element inside another <form>. Messing up forms and tables are two of the best ways to produces peculiar browser behaviour, so my guess is that this is your problem.
If you correct your HTML (validate it!) and the problem persists, then post a minimal HTML page with CSS so that there is something for us to debug.

Javascript/HTML Form field naming issue

Consider the following simple form:
<form method="GET" action="handle.php">
<input type="hidden" name="action" value="search">
</form>
Form submission is performed by Javascript (iui) in an ajax call. All fields are properly gathered from the form. Javascript then wants to send the ajax call to "form.action".
This is where my problem starts. The object form is of type HTMLFormElement. The action property of the form is supposed to be of type string and should contain "handle.php". After some hours of debugging, I noticed that form.action is now of type HTMLInputElement.
My question:
Is this proper Javascript behavior? I would have never though that defining a form field with the name of a form attribute, this would happen. In the mean time I solved the issue by naming my field differently.
Thanks in advance for any advice...
Found an easy way of displaying my problem. First the form with the problem:
<form action="test.php">
<input type="hidden" name="action" value="test">
<input type="button" onclick="alert(this.form.action);">
</form>
And the form that is proper:
<form action="test.php">
<input type="hidden" name="NOT_AN_ATTRIBUTE_NAME" value="test">
<input type="button" onclick="alert(this.form.action);">
</form>
In the first, the popup states "[object HTMLInputElement]", in the second: "http://localhost/test.php".
The issue you're seeing is because forms are special in JavaScript. All their fields are accessable as properties, so when you use this.form.action, it's getting the field action, not the HTML attribute action="test.php".
Try changing alert(this.form.action); to alert(this.form.getAttribute('action')) instead.
It seems as bug. Maybe there should be an array for 'action '
<form action="test.php">
<input type="hidden" name="action" value="test">
<input type="button" onclick="alert(this.form.action[0]);"> //the form action
<input type="button" onclick="alert(this.form.action[1]);"> // the text input
</form>
your this.form.action is still a object. instead of using alert put it in a console.log(this.form.action) and use firebug and firequery try to discover what events/properties your this.form.action has.
!you need to enable your console in firebug before you can use console.log

Categories