5 years ago

Onsubmit possible?

Posted 5 years ago by jediping

Building on what I learned in this tutorial series (, 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 ( 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('', $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.