question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documentation on creating dynamic forms doesn't specify a type for the button that adds an alias control

See original GitHub issue

Description

The example HTML code given in the Reactive forms documentation, chapter Creating dynamic forms lacks a button type for:

<button (click)="addAlias()">+ Add another alias</button>

This, in result, makes it a submit button as it is placed inside a form.

Updating the documentation to use:

<button type="button" (click)="addAlias()">+ Add another alias</button>

would prevent people from facing the issue of unwanted form submits and make the example code copied from the official documentation work out of the box.

It would also make searching out issues on Stack Overflow like (ngSubmit) is called when press ‘click’ button unnecessary to make the documented example work properly.

I could provide a PR for this but I’m not sure if the profile-editor.component.html file is the right one to change.

What is the affected URL?

https://angular.io/guide/reactive-forms#creating-dynamic-forms

Please provide the steps to reproduce the issue

For reproducing the issue we can use the profile-editor.component.html from the Reactive Forms live-example.

  1. Click the Profile editor button.
  2. Make the Console visible.
  3. Click + Add another alias button.
  4. The onSubmit() function from the profile-editor.component.ts is called and the form values are logged in the Console.

Please provide the expected behavior vs the actual behavior you encountered

Expected behaviour would be for the + Add another alias button to ONLY add another form control - instead of adding another form control AND submitting the form.

Please provide a screenshot if possible

The screenshot from the live example:

Angular-creating-dynamic-forms-button-type-issue

The code snippet from the docs:

Angular-creating-dynamic-forms-button-issue-int-html

Please provide the exception or error you saw

No response

Is this a browser-specific issue? If so, please specify the device, browser, and version.

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
little-pineconecommented, Sep 30, 2021

Thanks for the instructions! I will try to run the documentation and propose a Pull Request in the coming days.

0reactions
angular-automatic-lock-bot[bot]commented, Nov 3, 2021

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic Forms Known Issues - Salesforce Help
On a Dynamic Forms-based page, multiple instances of the same lookup field that look up to an object that's not supported in the...
Read more >
Dynamic forms angular 4 giving error "Cannot find control with ...
I have three tabs and by default first tab should open with details having form. I am generate each tab form ...
Read more >
ng-dynamic-forms documentation
NG Dynamic Forms is a rapid form development library based on the official Angular dynamic forms guide. It fully automates form UI creation...
Read more >
Docs • Svelte
With this, npm run build will generate HTML, JS and CSS files inside the ... It will be used if the component's consumer...
Read more >
Using the form designer - Product Documentation | ServiceNow
Mark as Solution button · Define task ... Configure list control settings for the list editor ... Create a formatter and add it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found