{"record":{"id":"556e612dad108e90","repo":"theonedev/onedev","slug":"could-not-find-form-parent-for-this","errorCode":null,"errorMessage":"Could not find Form parent for {this}","messagePattern":"Could not find Form parent for (.+?)","errorType":"exception","errorClass":"org.apache.wicket.WicketRuntimeException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java","lineNumber":732,"sourceCode":"\t * input for this component instance.\n\t * \n\t * @param convertedInput\n\t *            the converted input\n\t */\n\tpublic final void setConvertedInput(T convertedInput)\n\t{\n\t\tthis.convertedInput = convertedInput;\n\t}\n\n\t/**\n\t * @return The parent form for this form component\n\t */\n\tpublic Form<?> getForm()\n\t{\n\t\tForm<?> form = Form.findForm(this);\n\t\tif (form == null)\n\t\t{\n\t\t\tthrow new WicketRuntimeException(\"Could not find Form parent for \" + this);\n\t\t}\n\t\treturn form;\n\t}\n\n\n\t/**\n\t * Gets the request parameter for this component as a string.\n\t * \n\t * @return The value in the request for this component\n\t */\n\tpublic String getInput()\n\t{\n\t\tString[] input = getInputAsArray();\n\t\tif (input == null || input.length == 0)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\telse","sourceCodeStart":714,"sourceCodeEnd":750,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java#L714-L750","documentation":"FormComponent.getForm() throws WicketRuntimeException when Form.findForm(component) cannot locate an enclosing Form ancestor. Form components (text fields, checkboxes, buttons' processing) require a Form in their ancestry to participate in submission.","triggerScenarios":"Adding a TextField/required FormComponent to a container that is not inside any Form; component reparented outside the form at runtime; using form components inside panels added to a page without a Form.","commonSituations":"Building reusable panels containing input fields and forgetting the host page to wrap them in a Form; moving a component between containers dynamically; nesting panels where the Form is a sibling rather than an ancestor.","solutions":["Wrap the component (or its panel) inside a Form in the hierarchy","If using AjaxFallbackLink/panel outside forms, replace form components with plain links/models or add a Form","Check Form.findForm semantics: the Form must be an ancestor; reorder the container hierarchy if it is a sibling","For border/panel nesting, ensure the form encloses the panel's markup placement, not just its Java construction"],"exampleFix":"// before\nadd(emailField); // no form ancestor\n// after\nForm<Void> form = new Form<Void>(\"form\");\nform.add(emailField);\nadd(form);","handlingStrategy":"validation","validationCode":"boolean hasForm = Optional.ofNullable(component.getParent())\n    .map(p -> Form.findForm(component) != null).orElse(false);","typeGuard":null,"tryCatchPattern":"try {\n    Form<?> f = formComponent.getForm();\n} catch (WicketRuntimeException e) {\n    throw new IllegalStateException(\"Place \" + formComponent.getId() + \" inside a Form\");\n}","preventionTips":["Always construct input components inside a Form subtree","When re-parenting dynamically, verify a Form ancestor exists afterwards","Panels with form controls must be added inside a Form on the host page"],"tags":["wicket","form","component-hierarchy"],"backgroundTag":"invalid-argument-value","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}