Handling "Multiple Forms" on the Same Page

NOTE: Due to a complete and thorough update of the framework to the PHP 8.3+ standard, this and a single example from the others do not function correctly.

This example will be updated with the new logic sooner or later!

QCubed-4 only allows each front-end "web page" to only have a maximum of one Form class per a page. Because of the many issues of managing and maintaining formstate across multiple Forms, QCubed-4 simply does not allow for the ability to have multiple Forms per a page.

However, as the development of a QCubed-4 application matures, developers may find themselves wishing for this ability:

  • As Forms are initially developed for simple, single-step tasks (e.g. "Post a Comment," "Edit a Project's Name," etc.), developers may want to be able to combine these simpler QForms together onto a single, larger, more cohesive Form, utilizing AJAX to provide for a more "Single-Page Web Application" type of architecture.
  • Moreover, developers may end up with a library of these Forms that they would want to reuse in multiple locations, thus allowing for a much better, more modularized codebase.

Fortunately, the Panel control was specifically designed to provide this kind of "Multiple Form" functionality. In the example below, we create a couple of custom Panels to help with the viewing and editing of a Project and its team members. The comments in each of these custom controls explain how a custom Panel provides similar functionality to an independent, stand-alone Form, but also detail the small differences in how the certain events need to be coded.

Next, to illustrate this point further, we create a PersonEditPanel, which is based on the code generated PersonEditFormBase class.

Finally, we use a few Ajax and AjaxControl to tie them all together into a single-page web application.

View/Edit Example: Projects and Memberships

Please Select a Project: