Browse Source

Fix issue for `subjects#form`

pull/66/head
alexdbondoc17 4 years ago
parent
commit
0c54ce628e
  1. 4
      app/components/subject_index_form_component.rb
  2. 6
      app/components/subject_index_form_component/subject_index_form_component.html.erb

4
app/components/subject_index_form_component.rb

@ -4,10 +4,12 @@ class SubjectIndexFormComponent < BaseComponent
def initialize(current_user:, subject_index:, opts:) def initialize(current_user:, subject_index:, opts:)
@subject_index = subject_index @subject_index = subject_index
@opts = opts @opts = opts
@parent_id = @opts[:parent_id] @parent_id = opts[:parent_id]
end end
def parent def parent
return if parent_id.blank?
Cdao::Subject.find(parent_id) Cdao::Subject.find(parent_id)
end end

6
app/components/subject_index_form_component/subject_index_form_component.html.erb

@ -11,8 +11,10 @@
<div cass="row"> <div cass="row">
<div class="col-sm-12"> <div class="col-sm-12">
<strong> <%= label_tag :subjects %> </strong> <strong> <%= label_tag :subjects %> </strong>
<select class="form-control subjects-selectize ps-0 pe-0" name="parent_id" id="parent_id" value="<%= parent_id %>"> <select class="form-control subjects-selectize ps-0 pe-0" name="parent_id" id="parent_id">
<option value="<%= parent_id %>" selected="selected"> <%= parent.name %> </option> <% if parent_id.present? %>
<option value="<%= parent_id %>" selected="selected"> <%= parent.name %> </option>
<% end %>
</select> </select>
</div> </div>
</div> </div>

Loading…
Cancel
Save