Pressing enter clears date field
- Single Page
Posted 24 April 2012 - 16:53 PM
I have run into an issue:
In an edit screen (or add screen) I have a date field and several text input fields. I select the date and then tab to the next input field. I type information into the field (it doesn't matter if it's the immediate next field or down the list) and then accidentally hit the "Enter" key instead of tabbing to the next field. The date field is cleared.
Is this a known issue? Any workarounds?
Thanks.
Posted 24 April 2012 - 20:56 PM
Thank you to mention it.
Posted 27 April 2012 - 13:56 PM
Thanks.
Posted 27 April 2012 - 19:03 PM
Also make sure that the form is cleared EVERYTIME you insert something. So at the add form it is normal to clear all the form when you press the enter button. The enter button is a shortcut to save faster at your form. So you don't need to press the submit button. If you press enter at any input of the default form it has to be like saving the form.
So for example if you have:
[attachment=139:image-1.png]
and you press enter it is normal to insert the data and clear the form like the image below:
[attachment=140:image-2.png]
But the clearing form doesn't suppose to happen at the edit form. Are you sure that only the date field is cleared?
Posted 27 April 2012 - 20:38 PM
Here are the screenshots you requested (using the new Dutch language file ).
I have 2 date fields. Initially they are empty:
[attachment=141:enter1.png]
Then I start entering a date to each of those, using the datepicker, as usual:
[attachment=142:enter2.png]
So far so good, all fields that need data are entered:
[attachment=143:enter3.png]
Now I go to one of the other fields (could be any one of them, I just chose the one below the date fields here, but behavior is the same for all the other fields as well, even the date fields themselves):
[attachment=144:enter4.png]
And finally, if I press enter, one of the date fields becomes empty:
[attachment=145:enter5.png]
When pressing enter, I don't get the "data saved" message and all the other fields keep their contents. I have this behavior only for this form with the two date fields. On other forms without dates the fields get cleared and I see the "data saved" message. I'm using v1.2.1.1 and also tried the v1.2.2 lib file.
I hope this enables you to reproduce the issue.
Thanks!
Posted 27 April 2012 - 20:50 PM
If I remove the buttons altogether, by removing the following line from the grocery_crud lib file:
<button class='datetime-input-clear' tabindex='-1'>".$this->l('form_button_clear')."</button>
then I get the expected behavior with the "saved data" message:
[attachment=146:enter6.png]
[attachment=147:enter7.png]
Posted 28 April 2012 - 11:18 AM
Thank you for making so specific the problem.
Posted 30 April 2012 - 23:48 PM
I just want to share my knowledge with you because I don't want to believe that I just lose 1.5 hours of my life JUST to change the "button" to "a" .
So after a big research I find that the actual reason that happens is that the buttons are actually REALLY triggered with a click. So for example if you press enter and you see that the form is submitted automatically it doesn't trigger the event "submit" it is just "clicking" the FIRST submit button (in our case just button) and the form is sent.
So that's why if you have in a simple html form if you have:
<form action="">
<input name="test">
</form>
and you press enter at the input value NOTHING happens, but if you have:
<form action="">
<input name="test">
<button />
</form>
and you add a text at the input and just press ENTER the form is submitted as normal.
Posted 01 May 2012 - 00:36 AM
I applied the change and can inform that this issue has been solved. These few bytes really make a difference... Good to know that form submission is actually a click event on the first button. Thanks for sorting this out!
Posted 01 May 2012 - 13:13 PM