ember-bootstrap icon indicating copy to clipboard operation
ember-bootstrap copied to clipboard

Is using a path as property argument for <BsForm::Element> supported?

Open jelhan opened this issue 4 years ago • 3 comments

A consumer may try to use a path as @property argument for <BsForm::Element>. Is this officially supported? Should we support it?

<BsForm
  @model={{hash
    address=(
      hash street=""
     )
  }}
  as |form|
>
  <form.element @property="address.street" />
</BsForm>

It seems to have worked in the past but was broken due to refactoring at least if using ember-changeset-validations as validation provider. We started to address it in https://github.com/kaliber5/ember-bootstrap-changeset-validations/pull/28 but more bugs were catched in https://github.com/kaliber5/ember-bootstrap-changeset-validations/pull/30. Before fixing in validation plugin I want to discuss if we have or want to commit to support in Ember Bootstrap itself.

It's not covered by current API docs:

The property name of the form element's model (by default the model of its parent Components.Form) that this form element should represent. The control element's value will automatically be bound to the model property's value.

Using this property enables form validation on this element.

I haven't had the time yet to go through the tests and see if we have test coverage for it.

jelhan avatar Aug 07 '20 09:08 jelhan

I don't think this is really supported, at least I never had that explicitly in my mind. And I think that supporting that is probably not trivial with validations in mind. Like when using ember-cp-validations and you have an Ember.Object foo with the validation mixin, and another nested object with its own validations under the bar property, setting foo.bar would currently not allow us to see the validations defined on bar (when foo is the form's model).

Nevertheless it would be nice to add support for that in the future, but probably that will happen only as part (or thereafter) of a bigger validation API refactoring!?

simonihmig avatar Aug 07 '20 10:08 simonihmig

I'm not sure if I would see missing support in a validation provider plugin as a showstopper. We might support from Ember Bootstrap but it may not be supported by a specific validation provider (or it's plugin).

jelhan avatar Aug 07 '20 10:08 jelhan

Seems to run fine with 3.20... https://travis-ci.org/github/kaliber5/ember-bootstrap-changeset-validations/builds/716497258

For me that means I'm going to spend time upgrading my application and continue to use ember-bootstrap in an unofficially supported way...

basz avatar Aug 10 '20 10:08 basz