Hi I am new in ruby on rials, i want to get text_field value in a variable then this variable value send to MySql query and form_for using bootstrap model
I am sending the code please tell me where am i wrong..... thanks
this is edit button click on then call bootstrap model "#examplemodel1"
<div class="edit-recr-wrp1">
<button type="button" class="btn btn-primary fa fa-pencil-square-o" data-toggle="modal" data-target="#exampleModal1" data-whatever="<%= emp['offer_letter_id'] %>"></button>
</div>
this is my "#examplemodel1" call from above button
<div class="modal fade" id="exampleModal1" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
<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>
</div>
<div class="modal-body">
<div class="post-new-job head-border">
<div class="form-body">
<!-- edit employee information -->
<div class="mydata1">
<%= text_field :ol_id, { class: 'form-control', id: 'recipient-name' } %>
</div>
<%= form_for :employee_details, url: hr_path(:ol_id), method: :patch do |f| %>
<div class="col-md-12">
<div class="mydata">
<%= f.hidden_field :offer_letter_id, { class: 'form-control', id: 'recipient-name' } %>
</div>
<div class="form-group">
<label class="control-label">Employee ID</label>
<div class="input-group"> <span class="input-group-addon"> <i class="fa fa-user"></i> </span>
<%= f.text_field :employee_id, { :required => true, placeholder: 'E12345678', class: 'form-control' } %>
</div>
</div>
<div class="form-group">
<label class="control-label">Bank Account</label>
<div class="input-group"> <span class="input-group-addon"> <i class="fa fa-university"></i> </span>
<%= f.text_field :bank_ac, { :required => true, placeholder: '06464060852634865', class: 'form-control' } %>
</div>
</div>
<div class="form-group">
<label class="control-label">Bank IFSC Code</label>
<div class="input-group"> <span class="input-group-addon"> <i class="fa fa-code"></i> </span>
<%= f.text_field :bank_ifsc, { :required => true, placeholder: 'SBI012356', class: 'form-control' } %>
</div>
</div>
<div class="form-group">
<label class="control-label">End of Date</label>
<div class="input-group"> <span class="input-group-addon"> <i class="fa fa-calendar"></i> </span>
<%= f.text_field :work_end_date, { placeholder: 'MM/DD/YYYY', id: 'datepicker1', class:"datepicker_style" } %>
</div>
</div>
<div class="form-group">
<label class="control-label">Gender</label>
<div class="input-group"> <span class="input-group-addon"> <i class="fa fa-male fa-female"></i> </span>
<%= f.select :gender, ['Male', 'Female'], { :required => true }, class: "form-control" %>
</div>
</div>
<div class="form-group">
<label class="control-label">Spouse Name</label>
<div class="input-group"> <span class="input-group-addon"> <i class="fa fa-user"></i> </span>
<%= f.text_field :spouse_name, { :required => true, placeholder: 'Father/Mother/Wife name', class: "form-control" } %>
</div>
</div> <br>
<div class="form-group">
<a><%= f.submit "Edit Employee Details", :class => "btn btn-primary" %></a>
</div>
</div>
<div class="col-md-2"></div>
<%- end -%>
</div>
</div>
</div>
</div>
this is my jquery code
<script type="text/javascript">
$('#exampleModal1').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget)
var recipient = button.data('whatever')
var modal = $(this)
modal.find('.mydata1 input').val(recipient)
});
</script>
In this model offer_letter_id display into text_field:old_id
<div class="mydata1">
<%= text_field :ol_id, { class: 'form-control', id: 'recipient-name' } %>
</div>
But I can not take this value in a variable. I want to pass this value in url: hr_path(variable value)
<%= form_for :employee_details, url: hr_path(:ol_id), method: :patch do |f| %>
Aucun commentaire:
Enregistrer un commentaire