Orignal Yii demo app does not contains Reset button in Advanced Search form placed above any CGridView. I have developed one (discussed in this thread) and also provided a version that clears not CGridView header filter fields, but form fields instead (here).
The idea was to have Reset button working the same as Submit button - i.e. clearing all fields and updating CGridView via AJAX request without page reload (as in standard forms). In particular the code was:
$('#form-reset-button').click(function()
{
$('#search-form form input, #search-form form select').each(function(i, o)
{
if (($(o).attr('type') != 'submit') && ($(o).attr('type') != 'reset')) $(o).val('');
});
$.fn.yiiGridView.update('pacjenci-grid', {data: $('#search-form form').serialize()});
return false;
});
Now, what I want is to have just simple, pure Reset button which clears all the fields and then reloads the whole page (required to update CGridView but not via AJAX call this time, only in normal form process operation).
For this purpose, I commented out gridview update call and return false in above code, but that does not forces reset button to reload whole page. I managed to do so, by changing reset button to another submit button.
Now, it works as I wanted (clears all fields with above code and reload whole page), but the question is, if according to standards and coding practice, can I have two submit buttons in one form?
This line of code is commented-out (not deleted - for future references, i.e. my boss likes to change his mind often! :]). In current version it is not being executed, as there is no need to update CGridView via AJAX. It is being updated via standard request.
Yes! I know that. But it is not the only line of the code in this function. There are several more commented-out (as I just said - my boss likes to change his mind sometimes too often), I just didn’t paste them, not to waste space.