Joomla module development with form - how to handle

I am creating a simple Joomla 2.5 module that will be in the form of html.

mod_mymodule/tmpl/default.php:

<form method="post" id="myemailform" action="">
    <label for="ReferralName">Enter Name:</label><input type="text" name="name" value="<?php echo modCamcloudReferralHelper::getReferralName(); ?>">
    <label for="ReferralEmail">Enter Email Address:</label><input type="text" name="email">
    <label for="ReferralMessage">Enter Message (optional):</label><textarea class="message"></textarea>
    <span class="countdown"></span>
    <button type="submit" value="Send Email">Send Email</button>
    <?php echo JHtml::_('form.token'); ?>   
</form>

I have a helper class:

mod_mymodule/helper.php - it has only some utility functions.

My question is what is commonly used to process my form on the server side. I tried to find examples of what people did, but I cannot find anything. I just put everything in the helper class:

<form method="post" id="myemailform" action="..\helper.php">

Or something like that? Thanks in advance.

+5
source share
1 answer

Yes, you must process the form in a modular helper class. Save any logic from the template file, and you can use it mod_mymodule.phpto call helper methods and assign variables before including the view file.

! , , URL- .

: mod_mymodule.php

// include helper file
require_once dirname(__FILE__).'/helper.php';
// call some method of the helper class
$items = modMymoduleHelper::getItems();

$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'));
// render view file from mod_mymodule/tmpl/default.php, $items is available in the view file
require JModuleHelper::getLayoutPath('mod_mymodule', $params->get('layout', 'default'));
+3

All Articles