2017-06-29 2 views
-1

ich unterhalts Feld möchte in meiner Form verwenden, aber meine Eingabe ist HIDDE nicht Ich folgte diesem Tutorial https://www.driftingruby.com/episodes/dependent-form-fieldsAbhängige Feld ist nicht in meine Form versteckt

Mein application.js

//= require jquery 
//= require jquery.turbolinks 
//= require jquery_ujs 
//= require turbolinks 
//= require bootstrap-sprockets 
//= require now-ui-kit 
//= require bootstrap-datepicker 
//= require bootstrap-switch 
//= require moment.min 
//= require nouislider.min 
//= require jquery.bootstrap.wizard 
//= require jquery.validate.min 
//= require paper-bootstrap-wizard 
//= require underscore 
//= require dependent-fields 
//= require_tree . 

$(document).ready(function() { 
    DependentFields.bind() 
}); 

Meine Ansicht

<%= simple_form_for @contrat do |f| %> 
    <%= f.error_notification %> 
     <%= f.input :num_mandat, label: 'Numero Mandat' %> 
     <%= f.input :mandat_type, label: 'Type Mandat' %> 
     <%= f.input :client_type, label: 'Type de personne', collection: ['Physique', 'Morale'], id: 'client_choice' %> 
     <%= content_tag :div, class: 'js-dependent-fields', data: { 'data-select': 'client_choice', 'data-option-value': 'Physique'} do %> 
     <%= f.input :sexe_phi, collection: ['Mme', 'Mr'] %> 
     <% end %> 
     <%= f.button :submit, "Valider" %> 

Antwort

0

Versuchen Sie, Ihr Formular wie folgt zu ändern.

<%= simple_form_for @contrat do |f| %> 
    <%= f.error_notification %> 
    <%= f.input :num_mandat, label: 'Numero Mandat' %> 
    <%= f.input :mandat_type, label: 'Type Mandat' %> 
    <%= f.input :client_type, label: 'Type de personne', collection: ['Physique', 'Morale'], id: 'client_choice' %> 
    <%= content_tag :div, class: 'js-dependent-fields', data: { 'select-id': 'client_choice', 'option-value': 'Physique'} do %> 
     <%= f.input :sexe_phi, collection: ['Mme', 'Mr'] %> 
    <% end %> 
    <%= f.button :submit, "Valider" %> 
<% end %> 

Sie haben content_tag nicht ordnungsgemäß implementiert.

<%= content_tag :div, class: 'js-dependent-fields', data: { 'select-id': 'client_choice', 'option-value': 'Physique'} do %> 
    <%= f.input :sexe_phi, collection: ['Mme', 'Mr'] %> 
<% end %> 

Blick auf here für weitere Informationen.

+0

Danke für Ihre Hilfe Dipak, ich ändere meinen Code, aber es funktioniert immer noch nicht – Wako

Verwandte Themen