Currently, I have a form for creating a new Model named Route. This form includes a select field called takeover, which displays all existing Routes for the user to choose from and establish a relationship with the selected Route. The issue I am facing is that the newly created Route is also appearing in the select field, because I am using 'this.get('store').findAll('routes')' method. How can I prevent the newly created Model from being displayed in the selection dropdown, as it is not possible to create a relationship with itself.
Within the Route file, I start by initializing an empty Model which users can then fill out using the form:
//route.js
model() {
return this.store.createRecord('route', {});
},
Template:
//route.hbs
<form>
//input fields
//select-component code:
{{my-select
selected=model.takeover
options=routes
}}
</form>
The routes available for selection are defined within the route file:
//route.js
routes: Ember.computed(function () {
return this.get('store').findAll('route');
}).readOnly(),
At the moment, the list of selectable options includes all routes, including the new model. However, it should not be possible to select the model itself, so I need to remove it from the options. How can I achieve this?