×
Please submit new Bug Reports on GitHub: github.com/Jensen-Technologies/component-creator-issues/issues
Frontend save &new button and retaining some form values from previous
Nina
New Member
Posts: 10
4 năm 5 tháng trước #9725
bởi Nina
Frontend save &new button and retaining some form values from previous was created by Nina
I would like to add a button similar to "save2new" button in admin toolbar in my frontend form to add the ability to go back to the form for faster add of multiple items. I've been googling all week and I cant find anything about it. Anybody who knows how to do this?
I also would like some of the fields to retain value from previous submit but I can't figure out how to accomplish this either. I can see in the control function save that all values are cleared with
How do I clear the form only partially?
Any ideas are appreciated!
I also would like some of the fields to retain value from previous submit but I can't figure out how to accomplish this either. I can see in the control function save that all values are cleared with
$app->setUserState('com_mycomp.edit.view.data', NULL);
Any ideas are appreciated!
Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.
Søren Beck Jensen
Administrator
Posts: 81
4 năm 5 tháng trước - 4 năm 5 tháng trước #9726
bởi Søren Beck Jensen
Søren Beck Jensen
Founder, Component-Creator.com
Replied by Søren Beck Jensen on topic Frontend save &new button and retaining some form values from previous
The "correct" way to accomplish this would be to save the entered data into the users session and then populate that in the form. After saving you should then use $this->redirect($formUrl); in your controller to redirect back to the form instead of where it is redirecting you now.
But a fairly easy hack (potentially) could be to simply echo out <script>window.history.back();</script> which might do the trick. If clicking back in your browser after landing on the current page works, then so will this trick.
But a fairly easy hack (potentially) could be to simply echo out <script>window.history.back();</script> which might do the trick. If clicking back in your browser after landing on the current page works, then so will this trick.
Søren Beck Jensen
Founder, Component-Creator.com
Last edit: 4 năm 5 tháng trước by Søren Beck Jensen.
Những thành viên sau(s) đã Cảm ơn: johng, Nina
Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.
Nina
New Member
Posts: 10
4 năm 5 tháng trước #9727
bởi Nina
Replied by Nina on topic Frontend save &new button and retaining some form values from previous
Ok, I've changed the return url to return to the form but how do I get some (not all values) to remain after previous submit?
Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.
Søren Beck Jensen
Administrator
Posts: 81
4 năm 5 tháng trước #9728
bởi Søren Beck Jensen
Søren Beck Jensen
Founder, Component-Creator.com
Replied by Søren Beck Jensen on topic Frontend save &new button and retaining some form values from previous
That is more complicated. Maybe the easiest is to use jQuery to reset the fields you DON'T want to remember.
$('#fieldId').value('');
$('#fieldId').value('');
Søren Beck Jensen
Founder, Component-Creator.com
Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.
Nina
New Member
Posts: 10
4 năm 5 tháng trước #9731
bởi Nina
Replied by Nina on topic Frontend save &new button and retaining some form values from previous
Yes, disabling data flush in controller and adding a jQuery reset seems to do the trick! Thanks!
Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.
Thời gian tải trang: 0.052 giây