ruby: back_path = patient_transplants_recipient_dashboard_path(patient) .row.top .medium-6.columns = f.submit "Save", class: "button save-button" span= " or " = link_to "cancel", back_path .form-content = f.simple_fields_for :document, f.object.document do |fd| = render layout: "renalware/shared/fieldset", locals: { legend: "Transplant Outcomes", name: "transplant_failure", legend_note: "Bold items required for NHSBT" } do = f.input :graft_function_onset, wrapper: :horizontal_small, label_html: { class: "label-emphasis" } = f.input :last_post_transplant_dialysis_on, as: :date_picker, wrapper: :horizontal_datepicker, label_html: { class: "label-emphasis" } = f.input :stent_removed_on, as: :date_picker, wrapper: :horizontal_datepicker = f.input :return_to_regular_dialysis_on, as: :date_picker, wrapper: :horizontal_datepicker, label_html: { class: "label-emphasis" } / readonly: nil here is required to prevent the No option being created with readonly=readonly / which causes Capybara to fail because it cannot change the value of read-only element = f.input :transplant_failed, as: :inline_radio_buttons, wrapper: :horizontal_small, readonly: nil, label_html: { class: "label-emphasis" } = f.input :transplant_failed_on, as: :date_picker, wrapper: :horizontal_datepicker, label_html: { class: "label-emphasis" } = f.input :transplant_failure_cause_description_id, as: :grouped_select, collection: Renalware::Transplants::FailureCauseDescriptionGroup.all, group_method: :ordered_descriptions, group_label_method: :name, value_method: :id, wrapper: :horizontal_medium, label_html: { class: "label-emphasis" } = f.input :transplant_failure_cause_other, wrapper: :horizontal_medium = f.input :transplant_failure_notes, input_html: { rows: 5 }, wrapper: :horizontal_large = f.input :graft_nephrectomy_on, as: :date_picker, wrapper: :horizontal_datepicker, label_html: { class: "label-emphasis" } = render layout: "renalware/shared/fieldset", locals: { legend: "Cardiovascular Complication", name: "cardiovascular_complication" } do = fd.simple_fields_for :cardiovascular_complication, fd.object.cardiovascular_complication do |fcm| table.with-trailing-datepicker = render_input fcm, :myocardial_infact = render_input fcm, :peripheral_vascular_disease = render_input fcm, :stroke = render_input fcm, :transient_ischaemic_attack = render layout: "renalware/shared/fieldset", locals: { legend: "Observations", name: "observation" } do table.with-trailing-datepicker = render_input fd, :malignancy_within_first_3_months = render_input fd, :malignancy_within_first_12_months = render_input fd, :recipient_pregnancy = render_input fd, :acute_rejection_biopsy_proven = render_input fd, :primary_or_recurrent_renal_disease / followup.rejection_episodes can be dynamically added using the helpers in the cooon gem / We use accepts_nested.. on the server to rebuild the collection on save article.rejection-episodes header h2 Transplant Rejection = link_to_add_association "Add", f, :rejection_episodes, class: "button", data: { "association-insertion-node" => "#rejection-episodes", "association-insertion-method" => "append" } #rejection-episodes / It is important we do not try and SQL-order the episodes here as that discards the / unsaved ones that cocoon has kept around for us. So instead use #sort_by, allowing for / a nil recorded_on date if that value in a newly added and unsaved episode has not yet been / entered. - episodes = f.object.rejection_episodes.sort_by { |ep| ep.recorded_on || Time.zone.today } = f.simple_fields_for :rejection_episodes, episodes do |episode| = render "rejection_episode_fields", f: episode = render layout: "renalware/shared/fieldset", locals: { legend: "Admin", name: "admin" } do = f.input :notes, as: :text, input_html: { rows: 5 } .row .large-12.columns = f.submit "Save", class: "button save-button" span= " or " = link_to "cancel", back_path