Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text-field should support input filters #151

Closed
EnterpriseDT opened this issue Aug 4, 2015 · 9 comments
Closed

text-field should support input filters #151

EnterpriseDT opened this issue Aug 4, 2015 · 9 comments

Comments

@EnterpriseDT
Copy link

I'm seeing the error-message, TypeError: this.$parse_(...).assign is not a function. It's coming from form-for.js. Here's the full stack-trace:

TypeError: this.$parse_(...).assign is not a function
    at NestedObjectHelper.writeAttribute (http://localhost/portal/lib/angular/js/form-for.js:843:37)
    at FormForStateHelper.setFieldHasBeenModified (http://localhost/portal/lib/angular/js/form-for.js:2718:38)
    at target.validateField (http://localhost/portal/lib/angular/js/form-for.js:1169:39)
    at Object.<anonymous> (http://localhost/portal/lib/angular/js/form-for.js:1072:28)
    at Object.scopePrototype.$watch.arguments.(anonymous function) [as fn] (chrome-extension://ighdmehidhipcmcojjgiloacoafjmpfk/dist/hint.js:1905:36)
    at h.$get.h.$digest (http://localhost/portal/lib/angular/js/angular.min.js:110:373)
    at h.scopePrototype.$digest (chrome-extension://ighdmehidhipcmcojjgiloacoafjmpfk/dist/hint.js:1924:23)
    at h.$get.h.$apply (http://localhost/portal/lib/angular/js/angular.min.js:113:362)
    at h.scopePrototype.$apply (chrome-extension://ighdmehidhipcmcojjgiloacoafjmpfk/dist/hint.js:1987:22)
    at m (http://localhost/portal/lib/angular/js/angular.min.js:72:454)

I'm guessing I've got the wrong version of one of the includes or something, but I haven't managed to track it down yet. Do you have any ideas?

Thanks
Hans

@bvaughn
Copy link
Owner

bvaughn commented Aug 4, 2015

Sorry to hear that you're seeing an error. Can you provide a Plunker so I
can take a look?

$parse is a built-in Angular service so I'm not sure that a dependency is
to blame. Which versions of form for and Angular are you using?

On Monday, August 3, 2015, EnterpriseDT notifications@github.com wrote:

I'm seeing the error-message, TypeError: this.$parse_(...).assign is not
a function. It's coming from form-for.js. Here's the full stack-trace:

TypeError: this.$parse_(...).assign is not a function
at NestedObjectHelper.writeAttribute (http://localhost/portal/lib/angular/js/form-for.js:843:37)
at FormForStateHelper.setFieldHasBeenModified (http://localhost/portal/lib/angular/js/form-for.js:2718:38)
at target.validateField (http://localhost/portal/lib/angular/js/form-for.js:1169:39)
at Object. (http://localhost/portal/lib/angular/js/form-for.js:1072:28)
at Object.scopePrototype.$watch.arguments.(anonymous function) as fn
at h.$get.h.$digest (http://localhost/portal/lib/angular/js/angular.min.js:110:373)
at h.scopePrototype.$digest (chrome-extension://ighdmehidhipcmcojjgiloacoafjmpfk/dist/hint.js:1924:23)
at h.$get.h.$apply (http://localhost/portal/lib/angular/js/angular.min.js:113:362)
at h.scopePrototype.$apply (chrome-extension://ighdmehidhipcmcojjgiloacoafjmpfk/dist/hint.js:1987:22)
at m (http://localhost/portal/lib/angular/js/angular.min.js:72:454)

I'm guessing I've got the wrong version of one of the includes or
something, but I haven't managed to track it down yet. Do you have any
ideas?

Thanks
Hans


Reply to this email directly or view it on GitHub
#151.

@bvaughn bvaughn added the bug label Aug 4, 2015
@EnterpriseDT
Copy link
Author

I was about to try to isolate the error when I noticed that it's occurring for fields that have filters. Here's an example:

<text-field label="Discount" attribute="payment.discount | currency:'$'" disable="true"></text-field>

I guess filters are not supported in attributes?

@bvaughn
Copy link
Owner

bvaughn commented Aug 5, 2015

Oooh, no. Attributes are supposed to be the field name (e.g. username) or field path (e.g. user.firstName) within the form data object.

What are you trying to accomplish with the above filter? Is it just a display thing (prefixing the input value with "$" but not writing that value to the form-data object?)

@EnterpriseDT
Copy link
Author

Oops. Yes, it's just for formatting. It formats it OK, but I see now that
parsing doesn't work, which is understandable. How should I be doing this?

On 5 August 2015 at 11:30, Brian Vaughn notifications@github.com wrote:

Oooh, no. Attributes are supposed to be the field name (e.g. username) or
field path (e.g. user.firstName) within the form data object.

What are you trying to accomplish with the above filter? Is it just a
display thing (prefixing the input value with "$" but not writing that
value to the form-data object?)


Reply to this email directly or view it on GitHub
#151 (comment)
.

Regards
Hans Andersen
EnterpriseDT

@bvaughn
Copy link
Owner

bvaughn commented Aug 6, 2015

Hm, short answer is that there's no way to do this in formFor currently. Custom labels are easy but masking an input value is a request I haven't received before.

I'm open to the idea but I don't really have much spare time to build it myself. Any chance you may be interested in contributing some code? I'd be happy to review it :)

@EnterpriseDT
Copy link
Author

I apologize for my noobishness, but could you please explain the phrases
'custom labels' and 'masking an input value'. Neither or these mean
anything specific to me in the context of Angular.

On 6 August 2015 at 12:42, Brian Vaughn notifications@github.com wrote:

Hm, short answer is that there's no way to do this in formFor currently.
Custom labels are easy but masking an input value is a request I haven't
received before.

I'm open to the idea but I don't really have much spare time to build it
myself. Any chance you may be interested in contributing some code? I'd be
happy to review it :)


Reply to this email directly or view it on GitHub
#151 (comment)
.

Regards
Hans Andersen
EnterpriseDT

@bvaughn bvaughn changed the title TypeError: this.$parse_(...).assign is not a function text-field should support input masks Aug 6, 2015
@bvaughn bvaughn changed the title text-field should support input masks text-field should support input filters Aug 6, 2015
@bvaughn
Copy link
Owner

bvaughn commented Aug 6, 2015

No problem. It's not noobish. It's been a long day and my terminology is probably not good.

formFor supports configurable labels, by which I mean...you can choose the text (if any) that appears bolded before the input field. You can do this like so:

<text-field label="My Custom Label">

Angular also has the concept of filters that format values coming from the model before they're displayed in the view. This is what you were trying to use. Unfortunately formFor doesn't support theres- or rather, it doesn't unless you create your own custom input type. There's no way to hook into a formFor field's incoming value (from the model) to format it (before it's shown in the view).

@EnterpriseDT
Copy link
Author

EnterpriseDT commented Aug 6, 2015 via email

@bvaughn
Copy link
Owner

bvaughn commented Aug 6, 2015

Not a problem! Thanks for being so easy to chat with. :)

Going to close this issue for now then. If you change your mind about its importance- let's reopen it and talk more.

@bvaughn bvaughn closed this as completed Aug 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant