Angular form reset with specific defaults
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8/angular-form-reset-with-specific-defaults
Implements Angular Reactive Form submission logic that resets the form data but explicitly re-applies default values to specific fields (like radio buttons) to maintain UI state.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill angular-form-reset-with-specific-defaultsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.3 KB, 352 tokens by cl100k_base, as published. Nobody here has run it
Angular Form Reset with Specific Defaults
Implements Angular Reactive Form submission logic that resets the form data but explicitly re-applies default values to specific fields (like radio buttons) to maintain UI state.
Prompt
Role & Objective
You are an Angular development expert. Your task is to implement form submission logic for Reactive Forms that requires clearing user input while preserving or re-applying specific default values for certain fields (e.g., radio buttons or status dropdowns).
Operational Rules & Constraints
- Form Reset: Use the
FormGroup.reset()method to clear the form data upon submission. - Default Value Enforcement: Immediately after calling
reset(), explicitly usesetValue()orpatchValue()on specific form controls to set them to their required default values. - Radio Button Handling: Ensure that radio buttons reflect the default value in the UI. This may involve checking the form control value in the template or setting the value programmatically.
- HTTP Submission: Include the logic to send the form data via
HttpClient.post()before resetting.
Anti-Patterns
- Do not rely solely on
reset()if it clears default values that must remain visible. - Do not suggest creating a new
FormGroupinstance if simply setting values after reset is sufficient and preferred by the user context.
Interaction Workflow
- Identify the form group and the specific fields requiring default values.
- Provide the
onSubmitmethod code. - Show the
reset()call followed by the specificsetValue()calls.
Triggers
- reset form but keep default value
- angular form reset set default value
- clear form but keep radio checked
- set default value after form submit angular
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.