Joomla - How to make a form action work?

Asked

Viewed 35 times

0

I’m learning how to make a module of my own in Joomla. My module mod_monthly planning.php is like this:

//No direct access 
defined('_JEXEC') or die;
require_once dirname(__FILE__) . '/helper.php';

Jhtml::_('jquery.framework');
Jhtml::_('jquery.ui');
JHtml::_('behavior.formvalidator');
JHtml::script(JURI::base() . '/modules/mod_planejamentomensal/js/jquery-3.3.1.js');
JHtml::script(JURI::base() . '/modules/mod_planejamentomensal/js/jquery.mask.js');

my file default.php have my form (which has other fields and some functions in jQuery but I won’t put everything here so it doesn’t get too long:

 <div class="planj-mensal-form">
  <form method="post" name="frmCasdastra" class="form-validate" action="<?php JURI::base() . '/modules/mod_planejamentomensal/tmpl/adicionaForm.php' ?>">
    <div class="divTable">
        <div class="divTableRow">
            <div class="divTableColumn">
                <b>Solicitação nº:</b> <?php //echo $solicitacaoTemp; ?>
            </div>
        </div>


      <div class="divTableRow">
            <div class="divTableColumn divTableColumn1">
                <b>Agência:</b> <?php echo $grupo; ?>
            </div>
            <div class="divTableColumn divTableColumn2">
                <div class="divLabel"><label for="mes">Mês Referência:</label></div>
                <div class="divInput">
                <select name="mes">
                <?php 
                    $select = $planMensal->setSelect($mes, 'mes', date('m',strtotime('+1 month'))); 
                    echo $select;
                ?>
                </select>
                </div>
           </div>
        </div>
            <div class="divTableRow">
            <div class="divtableColumnBotao">
                <div class="divInput">
                    <input name="add" type="button" value="Adicionar mais um formulário" id="add">
              </div>
            </div>
        </div>
    </div>
  </form>  
</div>

So, the action of my form above is pointing to the file addiForm.php. My added fileForm.php looks like this:

 <?php

 defined('_JEXEC') or die;

$input = new JInput;
$teste = $input->get('mes',null);

echo "Show: ".$teste;
?>

But when I click on the Ubmit button nothing happens... I know there must be something there about Joomla that I’m doing wrong.. I tried to read the Joomla forms documentation but I didn’t understand much and I also didn’t find any more explanations or examples on the internet. Could someone give me some hint, please?

1 answer

0

Okay, first I thought my action address was wrong somehow but I got a response from another site. My code was not working because of button input type.

I’ve changed from:

<input name="add" type="button" value="Adicionar mais um formulário" id="add">

To:

 <input name="add" type="submit" value="Adicionar mais um formulário" id="add">

And it worked normally!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.