In my tml I have form whos fields are updated by a zone
Simplified tml:
<form t:id="editUserForm" t:zone="editRefresh" t:type="form">
<label>Search For User to Edit: </label>
<input type="text" id="editUser" />
<t:any
t:id="addNew"
element="button"
t:mixins="observe"
event="click"
zone="editRefresh"
fields ="['editUser']" >
Edit Selected User
</t:any>
<t:zone t:id="editRefresh">
...Fields here updated
<input t:type="submit" t:id="editUserButton" value="Edit User" />
</t:zone>
</form>
The fields are populated without issue however when submitting the form I am greeted with:
Render queue error in SetupRender[app/Administration:editloginname]: Component app/Administration:editloginname must be enclosed by a Form component.
Upon checking the log the backend code is still executed and then this error is thrown.
Also - is there a way to have the page refresh on Submit? I have specified a t:zone in the form tag so the form does not refresh when the t:any button is pressed and the zone updates however when the form is submitted I would like to have it work as per usual.
As a workaround I injected the page the form is on and changed
return editRefresh.getBody();
To
return adminPage;
This works OK as a workaround but isn't what I'd consider ideal.
You cannot render form fields without containing form. This is because Tapestry stores some internal state in form's hidden input when it renders its fields, and if you render the field separately from the form you'll end up with invalid form state.
See this answer for available options: https://stackoverflow.com/a/27961175/2414933
As for refreshing a page on submit: you can continue to use your workaround as it's perfectly valid. If you don't want to couple component with containing page you can handle form submission event on the page level and return this;
(remember Tapestry events are bubbled).
Or remove the t:zone
attribute from the form component. Without the t:zone
form submission won't use AJAX.