Onsubmit possible?

Posted 4 years ago by jediping

Building on what I learned in this tutorial series (https://www.flynsarmy.com/2015/02/creating-a-basic-todo-application-in-laravel-5-part-1/), I have created an index of my countries, with the option to delete a country. That all works fine, but I'd love to be able to add a confirmation dialog to the delete option.

I did a lot of googling and forum-searching, and I found a thread (http://stackoverflow.com/questions/26625584/confirm-delete-with-laravel-form) that seems to imply I can just add 'onsubmit' => 'return ConfirmDelete()' to the Form::open array, like this:

{!! Form::open(array('class' => 'form-inline', 'method' => 'DELETE', 'route' => array('countries.destroy', $country->slug)),'onsubmit' => 'return ConfirmDelete()') !!}
                    <a href="{{ route('countries.show', $country->slug) }}">{{ $country->country }}</a> - {{ $country->region }}
                    (
                    {!! link_to_route('countries.edit', 'Edit', array($country->slug), array('class' => 'btn btn-info')) !!},
                    {!! Form::submit('Delete', array('class' => 'btn btn-danger')) !!}
                    )
                    {!! Form::close() !!}

However, trying that gives me "syntax error, unexpected '=>' (T_DOUBLE_ARROW)." So, I assume I can't do that. Being new to Laravel, I'm not sure if I'm just not using the right search terms or what. Any help on how to create a confirmation dialog on this delete form would be appreciated!

Please sign in or create an account to participate in this conversation.