0

Here is my code

        <td>
            <g:form resource="${this.stock}" method="DELETE">
                <g:link id="${stock.id}" class="btn btn-primary" action="edit" resource="${this.stock}"><g:message code="default.button.edit.label" default="Edit" /></g:link>
                <input class="btn btn-warning" type="submit" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
            </g:form>
        </td>

Edit button is working but Delete Button is not working. Whats wrong here?

Syed Sarek
  • 373
  • 2
  • 12
  • 1
    Hard to make out what you are doing you have a form with method DELETE then inside it a link to action edit - please review your code and what you are attempting to actuall do. the form action is ?? https://stackoverflow.com/questions/5162960/should-put-and-delete-be-used-in-forms is this a normal form if so it should be action="delete" or what ever action form should be going to – V H Jun 11 '17 at 10:30
  • I'm using this form as a column of a table where I want to use 2 action (Edit & Delete). I have taken this code from show.gsp – Syed Sarek Jun 12 '17 at 05:27
  • So you've taken the code above from show.gsp & put it in your own gsp? What does the action look like that feeds the gsp? – Mike W Jun 12 '17 at 06:06

1 Answers1

0

See grails documentation,

As mentioned there in last line, form method to use is either GET or POST, you cannot specify DELETE as form method type.

better if you use <g:actionSubmit>, instead of <input type="submit"/> for more info on <g:actionSubmit>, see this link

Also mention action name, where it redirect on submition of form.

Hope this works, try this , and if you still have any queries , let me know.

yash
  • 2,101
  • 2
  • 23
  • 32