<div data-controller="dynamic-select" data-dynamic-select-url-value="<%= filtered_projects_organizations_path %>" data-dynamic-select-selected-value="<%= task.project_id %>" > <%= form.label :organization_id %> <%= form.select :organization_id, Organization.all.map { |o| [o.name, o.id] }, { prompt: 'Please select an organization' }, { "data-action": "change->dynamic-select#updateProjects", "data-dynamic-select-target": "mainSelect" } %> </div> <div> <%= form.label :project_id %> <%= form.select :project_id, [], { prompt: 'Please select a project' }, { "data-dynamic-select-target": "secondarySelect" } %> </div>