<% content_for :title, "Create a new organisation" %> <% content_for :before_content do %> <%= govuk_back_link(href: :back) %> <% end %> <%= form_for(@organisation, as: :organisation, html: { method: :post }) do |f| %>
<%= f.govuk_error_summary %>

<%= content_for(:title) %>

<%= f.govuk_text_field :name, label: { size: "m" }, autocomplete: "name" %> <%= f.govuk_text_field :address_line1, label: { text: "Address line 1", size: "m" }, autocomplete: "address-line1" %> <%= f.govuk_text_field :address_line2, label: { text: "Address line 2", size: "m" }, autocomplete: "address-line2" %> <%= f.govuk_text_field :postcode, label: { size: "m" }, autocomplete: "postal-code", width: 10 %> <%= f.govuk_phone_field :phone, label: { text: "Telephone number", size: "m" }, autocomplete: "tel", width: 20 %> <%= f.govuk_text_field :housing_registration_no, label: { text: "Regulator of Social Housing registration number", size: "m" }, width: 10 %> <% null_option = [OpenStruct.new(id: "", name: "Select an option")] %> <% types = Organisation::PROVIDER_TYPE.map { |key, _val| OpenStruct.new(id: key, name: Organisation::DISPLAY_PROVIDER_TYPE[key]) } %> <% type_answer_options = null_option + types %> <%= f.govuk_collection_select :provider_type, type_answer_options, :id, :name, label: { text: "Organisation type", size: "m" }, options: { disabled: [""], selected: @organisation.provider_type || "" } %> <%= f.govuk_collection_radio_buttons :holds_own_stock, [OpenStruct.new(id: true, name: "Yes"), OpenStruct.new(id: false, name: "No")], :id, :name, legend: { text: "Does the organisation hold its own stock?", size: "m" } %> <% group_organisation_options = [OpenStruct.new(id: "", name: "")] + Organisation.visible.map { |org| OpenStruct.new(id: org.id, name: org.name) } %> <%= f.govuk_radio_buttons_fieldset :group_member, legend: { text: "Is this organisation part of a housing provider group structure?", size: "m" } do %> <%= f.govuk_radio_button :group_member, true, label: { text: "Yes" }, "data-controller": "conditional-question", "data-action": "click->conditional-question#displayConditional", "data-info": { conditional_questions: { group: [true] }, type: "organisation" }.to_json do %> <%= f.govuk_collection_select :group, group_organisation_options, :id, :name, label: { text: "Search for an organisation that is part of the same group as this organisation", size: "m" }, options: { disabled: [""], selected: @organisation.group || "" }, "data-controller": %w[accessible-autocomplete conditional-filter] %> <% end %> <%= f.govuk_radio_button :group_member, false, label: { text: "No" } %> <% end %> <% profit_options = [ OpenStruct.new(id: 1, name: "Non-profit"), OpenStruct.new(id: 2, name: "Profit"), OpenStruct.new(id: 3, name: "Local authority") ] %> <%= f.govuk_collection_select :profit_status, profit_options, :id, :name, label: { text: "Is the organisation for-profit?", size: "m" }, options: { disabled: [""], selected: @organisation.profit_status || "" } %> <%= f.govuk_check_boxes_fieldset :rent_periods, legend: { text: "What are the rent periods for the organisation?" } do %> <% @rent_periods.map do |key, period| %> <%= f.govuk_check_box :rent_periods, key, label: { text: period["value"] }, checked: period[:checked] %> <% end %> <% end %> <%= f.govuk_submit "Create organisation" %>
<% end %>