Files
grecia/app/views/relationable/_form.html.erb
Javi Martín adfb141d1b Simplify URL validation in related content
We were using `Setting["url"]` to verify the content belonged to the
application URL, but we can use `root_url` instead.

Note that means we need to include the port when filling in forms in the
tests, since in tests URL helpers like `polymorphic_url` don't include
the port, but a port is automatically added when actually making the
request.
2022-10-02 16:54:06 +02:00

27 lines
1.0 KiB
Plaintext

<button type="button" data-toggle="related_content" class="add-related-content">
<%= t("related_content.add") %>
</button>
<%= form_tag related_contents_path, method: :post, id: "related_content", "data-toggler": "unused-toggle-class" do %>
<label for="url"><%= t("related_content.label") %></label>
<p class="help-text" id="related_content_help_text">
<%= t("related_content.help", models: t("related_content.content_title").values.to_sentence, org: setting["org_name"]) %>
</p>
<div class="input-group">
<div class="input-group-field">
<%= text_field_tag :url, "",
"aria-describedby": "related_content_help_text",
placeholder: t("related_content.placeholder", url: root_url) %>
<%= hidden_field_tag :relationable_klass, relationable.class.name %>
<%= hidden_field_tag :relationable_id, relationable.id %>
</div>
<div class="input-group-button">
<%= submit_tag t("related_content.submit"), class: "button" %>
</div>
</div>
<% end %>