angular-xeditable icon indicating copy to clipboard operation
angular-xeditable copied to clipboard

No way to access edit fields (editables) by name

Open piotr-dobrogost opened this issue 8 years ago • 9 comments

I was looking for a method to access specific editable fields of a form by name but it seems there's no such a method. Basically the implementation would be very similar to $activate (https://github.com/vitalets/angular-xeditable/blob/0.8.0/src/js/editable-form/controller.js#L173-L182).

piotr-dobrogost avatar Oct 13 '17 16:10 piotr-dobrogost

Can you add some more specific on what you are trying to achieve?

ckosloski avatar Oct 13 '17 18:10 ckosloski

In my case some fields should only be editable when adding new entries and not when editing existing ones. That is why upon entering edit mode I hide edit fields which are not meant to be used when editing (as opposed to adding) entry. I guess better approach on my side would be to use something like ng-show and conditionally show edit fields based on weather user is editing already existing entry or adding a new one. Though I'm not sure how to go about accessing mode (add/edit) in ng-show attribute of edit fields?

piotr-dobrogost avatar Oct 16 '17 13:10 piotr-dobrogost

Yes, one way to do that is do the ng-if based upon the unique key of the row. If no id exists, don't show fields, if id exists, show fields.

ckosloski avatar Oct 16 '17 13:10 ckosloski

Ok, in this case I'm going to change approach. Still I guess there should be easy way to access edit fields by name in more advanced scenarios. Closing for now. I guess if more people want this then this issue could be reopened later.

piotr-dobrogost avatar Oct 16 '17 20:10 piotr-dobrogost

If you decide to investigate you original issue some more and find a solution, please create a pull request.

ckosloski avatar Oct 16 '17 20:10 ckosloski

Would like to revisit this. Does angular-xeditable create underneath standard AngularJS input component (one from those listed at https://docs.angularjs.org/api/ng/input) and if so then how to access it from (or pass into) onbeforesave() function? Such a component has for example $valid and $error properties.

piotr-dobrogost avatar Mar 20 '18 11:03 piotr-dobrogost

Are you trying to use angular's built in validations? If so, this project is not setup to use them. There are several issues that haven been opened for this, here is #76 .

ckosloski avatar Mar 20 '18 13:03 ckosloski

It looks like you linked this issue by mistake.

piotr-dobrogost avatar Mar 20 '18 15:03 piotr-dobrogost

Fixed it

ckosloski avatar Mar 20 '18 15:03 ckosloski