Reputation: 2019
I am using grails 2.4.2 and bootstrap. Now I need to use bootstrap modal to edit a individual row on click a button. It means that when I will click the action button the modal will open with form element. After giving value in the modal field I want to press the save change button to call controller action but its not happening.Can anyone please help me on this please? Here are my attempts below ::
the button form where I am opening the modal in edit form ::
<span>
<a href="" title="Change File" data-toggle="modal" data-target="#myModal">
<span class="glyphicon glyphicon-edit"></span>
</a>
</span>
my modal & elements ::
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Edit Add Video</h4>
</div>
<g:form controller="video" action="updateAddVideo" method="PUT" enctype="multipart/form-data" >
<div class="modal-body">
<div class="panel panel-info">
<div class="panel-heading">
<h5>Edit</h5>
</div>
<div class="panel panel-body">
<div class="col-md-12">
<g:hiddenField name="addVideoId" value=""/>
<div class="col-md-12">
<label>Add Title</label>
<g:textField name="addTitle" required="" class="form-control"/>
</div>
<div class="col-md-12">
<label>Upload Add Video</label>
<input type="file" id="videoName" name="videoName" required="" class="form-control"/>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</g:form>
</div>
</div>
</div>
Upvotes: 0
Views: 1288
Reputation: 371
It looks like you might need to change your <button>
tags to be of type <input type="submit"...>
.
The button element does not automatically cause a submit action when pressed, unless you add code to the "onClick" property to do so. Using a input type submit button should tell the form to submit to its controller.
Alternatively, look into grails "actionSubmit" tag, which works with g:form. Grails Documentation
Upvotes: 1