refactor($core): handle properly selected value for has_many and belongs_to