vitalets / angular-xeditable

Edit in place for AngularJS
http://vitalets.github.io/angular-xeditable
MIT License
1.91k stars 403 forks source link

No way to access edit fields (editables) by name #696

Open piotr-dobrogost opened 7 years ago

piotr-dobrogost commented 7 years ago

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).

ckosloski commented 7 years ago

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

piotr-dobrogost commented 7 years ago

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?

ckosloski commented 7 years ago

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.

piotr-dobrogost commented 7 years ago

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.

ckosloski commented 7 years ago

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

piotr-dobrogost commented 6 years ago

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.

ckosloski commented 6 years ago

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 .

piotr-dobrogost commented 6 years ago

It looks like you linked this issue by mistake.

ckosloski commented 6 years ago

Fixed it