[{"data":1,"prerenderedAt":349},["ShallowReactive",2],{"content-\u002Fdocs\u002Fwriting-and-mutating\u002Freset":3},{"id":4,"title":5,"body":6,"description":327,"extension":328,"meta":329,"metaRows":330,"navigation":343,"path":344,"seo":345,"source":346,"stem":347,"__hash__":348},"docs\u002Fdocs\u002Fwriting-and-mutating\u002Freset.md","reset & resetField",{"type":7,"value":8,"toc":316},"minimark",[9,21,34,37,51,55,62,86,105,140,145,152,155,182,191,202,209,229,235,251,254,258,282,286,312],[10,11,13,17,18],"h1",{"id":12},"reset-resetfield",[14,15,16],"code",{},"reset"," & ",[14,19,20],{},"resetField",[22,23,24],"blockquote",{},[25,26,27,28,30,31,33],"p",{},"The defaults are the destination: ",[14,29,16],{}," for the whole form, ",[14,32,20],{}," for one path. Both wipe state along with values.",[35,36],"docs-meta-table",{},[25,38,39,40,42,43,46,47,50],{},"Type into any field to flip it dirty. Click ",[14,41,20],{}," to restore one path; click ",[14,44,45],{},"reset()"," to restore everything; click ",[14,48,49],{},"reset(newDefaults)"," to redirect the defaults AND restore in one call. The dirty markers and the form-level pristine\u002Fdirty status update reactively as state reset propagates.",[52,53],"docs-demo",{"label":54,"slug":16},"Reset Demo",[56,57,59,61],"h2",{"id":58},"reset-restores-defaults",[14,60,45],{}," restores defaults",[63,64,69],"pre",{"className":65,"code":66,"language":67,"meta":68,"style":68},"language-ts shiki shiki-themes github-light github-dark","form.reset()\n","ts","",[14,70,71],{"__ignoreMap":68},[72,73,76,80,83],"span",{"class":74,"line":75},"line",1,[72,77,79],{"class":78},"sVt8B","form.",[72,81,16],{"class":82},"sScJk",[72,84,85],{"class":78},"()\n",[25,87,88,89,92,93,96,97,100,101,104],{},"Every path goes back to its ",[14,90,91],{},"defaultValues"," entry, or, where no override was given, to the schema-slim default (",[14,94,95],{},"''"," for strings, ",[14,98,99],{},"0"," for numbers, ",[14,102,103],{},"false"," for booleans). Alongside the value reset:",[106,107,108,115,120,126],"ul",{},[109,110,111,114],"li",{},[14,112,113],{},"dirty"," flips false on every leaf.",[109,116,117,114],{},[14,118,119],{},"touched",[109,121,122,125],{},[14,123,124],{},"errors"," clear at every path.",[109,127,128,131,132,135,136,139],{},[14,129,130],{},"meta.submissionAttempts",", ",[14,133,134],{},"meta.submitted",", and ",[14,137,138],{},"meta.submitError"," all zero (the submission surface returns to its initial state).",[25,141,142,144],{},[14,143,45],{}," is the right call after a successful submit when you want the form to look fresh, or when a \"Discard changes\" button needs to back out unsaved edits.",[56,146,148,151],{"id":147},"resetnextdefaults-redirects-defaults",[14,149,150],{},"reset(nextDefaults)"," redirects defaults",[25,153,154],{},"Pass a new defaults object to update the form's defaults AND reset in one step:",[63,156,158],{"className":65,"code":157,"language":67,"meta":68,"style":68},"form.reset({ name: 'New Default', email: 'new@example.com' })\n",[14,159,160],{"__ignoreMap":68},[72,161,162,164,166,169,173,176,179],{"class":74,"line":75},[72,163,79],{"class":78},[72,165,16],{"class":82},[72,167,168],{"class":78},"({ name: ",[72,170,172],{"class":171},"sZZnC","'New Default'",[72,174,175],{"class":78},", email: ",[72,177,178],{"class":171},"'new@example.com'",[72,180,181],{"class":78}," })\n",[25,183,184,185,187,188,190],{},"After this call, the new object IS the form's defaults for any subsequent ",[14,186,45],{}," or ",[14,189,20],{}," call. Useful when the form needs to switch contexts: editing record A then loading record B's values as the new baseline.",[25,192,193,194,197,198,201],{},"The argument is a ",[14,195,196],{},"Partial\u003CDefaultValuesInput\u003CForm>>",". Fields you don't mention pick up the previous defaults. Pass ",[14,199,200],{},"{}"," to reset with no changes to the defaults.",[56,203,205,208],{"id":204},"resetfieldpath-restores-one-path",[14,206,207],{},"resetField(path)"," restores one path",[63,210,212],{"className":65,"code":211,"language":67,"meta":68,"style":68},"form.resetField('email')\n",[14,213,214],{"__ignoreMap":68},[72,215,216,218,220,223,226],{"class":74,"line":75},[72,217,79],{"class":78},[72,219,20],{"class":82},[72,221,222],{"class":78},"(",[72,224,225],{"class":171},"'email'",[72,227,228],{"class":78},")\n",[25,230,231,232,234],{},"Same semantics as ",[14,233,45],{},", scoped to a single path:",[106,236,237,240,248],{},[109,238,239],{},"Value goes back to the path's default.",[109,241,242,244,245,247],{},[14,243,113],{}," and ",[14,246,119],{}," flip false at that path.",[109,249,250],{},"Errors at that path clear.",[25,252,253],{},"Useful when one field's been edited but the user wants to discard just that change while keeping the rest of the form's edits in place.",[56,255,257],{"id":256},"reset-vs-clear","Reset vs clear",[25,259,260,244,262,264,265,269,270,277,278,281],{},[14,261,16],{},[14,263,20],{}," go to ",[266,267,268],"strong",{},"defaults",". ",[271,272,274],"a",{"href":273},"\u002Fdocs\u002Fwriting-and-mutating\u002Fclear",[14,275,276],{},"clear"," goes to ",[266,279,280],{},"blank",": the schema-slim empty value, skipping defaults. Pick reset when \"back to baseline\" is the goal; pick clear when \"wipe to zero\" is.",[56,283,285],{"id":284},"where-to-next","Where to next",[106,287,288,298,305],{},[109,289,290,297],{},[271,291,293,296],{"href":292},"\u002Fdocs\u002Fwriting-and-mutating\u002Fset-value",[14,294,295],{},"setValue"," patterns",": write specific values without going through defaults.",[109,299,300,304],{},[271,301,302],{"href":273},[14,303,276],{},": wipe to blank values, defaults intentionally skipped.",[109,306,307,311],{},[271,308,310],{"href":309},"\u002Fdocs\u002Fsubmitting\u002Fhandle-submit","Submit lifecycle",": handlers that pair reset with successful submits.",[313,314,315],"style",{},"html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}",{"title":68,"searchDepth":317,"depth":317,"links":318},2,[319,321,323,325,326],{"id":58,"depth":317,"text":320},"reset() restores defaults",{"id":147,"depth":317,"text":322},"reset(nextDefaults) redirects defaults",{"id":204,"depth":317,"text":324},"resetField(path) restores one path",{"id":256,"depth":317,"text":257},{"id":284,"depth":317,"text":285},"reset() restores the whole form to its defaults; resetField(path) restores one field. Both wipe dirty \u002F touched state along with the value.","md",{},[331,334,337,340],{"label":332,"value":333},"Category","Return method",{"label":335,"value":336,"kind":14},"Signatures","reset(nextDefaults?) · resetField(path)",{"label":338,"value":339},"Restores","value, dirty, touched, errors at scope",{"label":341,"value":342,"kind":14},"Returns","void",true,"\u002Fdocs\u002Fwriting-and-mutating\u002Freset",{"title":5,"description":327},null,"docs\u002Fwriting-and-mutating\u002Freset","CQK3x5IjGwFiPJ9so6Ot3bR-CKD5_45_Q7F9O3JZ84k",1780949759704]