Sha256: 3bc530f1feb9190690528102dec70e8711e394edab13aa0618180070deebd5a8
Contents?: true
Size: 1.32 KB
Versions: 6
Compression:
Stored size: 1.32 KB
Contents
<%= simple_form_for([:admin, @document, @document_distribution]) do |f| %> <%= f.error_notification %> <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> <div class="form-inputs"> <%= f.input :friendlier_id, input_html: { value: @document.friendlier_id, readonly: true } %> <%= f.input :reference_type_id, as: :select, collection: ReferenceType.all.map { |r| [r.reference_type, r.id] }, label: 'Reference Type' %> <%= f.input :url, label: 'Distribution URL' %> <%= f.input :label, autofocus: true, input_html: { disabled: true, id: 'label-input' } %> </div> <div class="form-actions"> <%= f.button :submit, 'Create Download URL', {class: 'btn btn-primary'} %> </div> <% end %> <script> document.addEventListener('DOMContentLoaded', function() { const distributionSelect = document.querySelector('select[name="document_distribution[reference_type_id]"]'); const labelInput = document.getElementById('label-input'); function toggleLabelInput() { if (distributionSelect.options[distributionSelect.selectedIndex].text === 'Download') { labelInput.disabled = false; } else { labelInput.disabled = true; } } distributionSelect.addEventListener('change', toggleLabelInput); toggleLabelInput(); // Initial check }); </script>
Version data entries
6 entries across 6 versions & 1 rubygems