Skip to content

Remove form element from multiple input field #715

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

Closed
anushkamds opened this issue Jun 14, 2016 · 7 comments
Closed

Remove form element from multiple input field #715

anushkamds opened this issue Jun 14, 2016 · 7 comments

Comments

@anushkamds
Copy link

As a developer, when I save a value in particular input field (Refer attached image) I should be able to remove that whole element from the list. So is it possible to do it or is there any way to do that (I'm using latest version 0.8.13)

List of form element

@Anthropic
Copy link
Member

I need a gist of what you are doing to be able to help, an image doesn't provide enough information for anyone to support your issue.

The example demo has a "Save to Gist" button you can use to create one from a schema and form definition.

@anushkamds
Copy link
Author

Scenario is like this. Initial, I have 'Add List' button then I click Add List button so if it display a new field with Input field with save button. It is possible to add any number of fields like that. Then, it is needed to input some thing on input filed and then click save.
So when someone click save button, it is needed to save the data and remove that particular field (Same behaviour which is done by the 'X' icon at top of each field).
I hope this clarify the scenario what i am looking for and information needs for you.
Rgs,
Anushka

@Anthropic
Copy link
Member

Take a look at the example page and look at the array example. You can add any field type inside an array including a button, by default the array will also have an X for removal and you can listen for Angular destroy events to capture the backend changes you need.

Please re-open if you do not feel the question has been answered sufficiently :)

@anushkamds
Copy link
Author

Hi @Anthropic, what i need is, it needs to remove that particular array element which user click save button with out any user interaction. User clicks save button and that field is remove from the form array. How can i user angular destroy event for that ??

@Anthropic
Copy link
Member

@anushkamahesh in that case you would have the function called by the save button handle it all, so you don't need the destroy event for that case, just call your save function and on confirmation from the server that it was saved, splice the item out of your array.

@anushkamds
Copy link
Author

Here is example view https://embed.plnkr.co/NT6cvVybfuZnFIhgU1Xm/. In order to slice in need to get the particular index of the array to the controller how can i do that

@Anthropic
Copy link
Member

@anushkamahesh there is a PR in progress #652 to help make this easier as it currently only works if the array is not nested. If it isn't nested then there is an arrayIndex value available to pass to your function, but I think that will work better one the above PR is merged.

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

2 participants