jimport('joomla.form.form'); // Define the path to the custom forms folder $formPath = JPATH_SITE . '/forms/custom'; // Add the path to JForm JForm::addFormPath($formPath); // Load a form from the custom folder $form = JForm::getInstance('my_form', $formPath); // Render the form echo $form->render();
jimport('joomla.form.form'); // Define an array of custom form paths $formPaths = array( JPATH_SITE . '/forms/custom', JPATH_SITE . '/forms/legacy' ); // Add the paths to JForm foreach($formPaths as $formPath) { JForm::addFormPath($formPath); } // Load a form from the custom folder $form = JForm::getInstance('my_form', $formPaths); // Render the form echo $form->render();In this example, we define an array of custom form paths and add them to JForm using a loop that calls the addFormPath function. We then load a form from one of the custom directories and render it to the page using the getInstance and render functions. The JForm function and its addFormPath method are part of the Joomla Platform library.