Joomla - How to make a form's action work?

0

I'm learning how to make a module itself in Joomla. My module mod_planejamentomensal.php looks 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 default file has my form (which has other fields and some functions in jQuery but I will not put everything here so it does not 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 on my form above is pointing to the addForm.php file. My file addsForm.php looks like this:

 <?php

 defined('_JEXEC') or die;

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

echo "Show: ".$teste;
?>

But when I click the submit button nothing happens ... I know there must be something there in relation to Joomla that I'm doing wrong .. I tried to read the documentation of Joomla forms but I did not understand much and also I did not find further explanations or examples on the internet. Could someone give me some hint, please?

    
asked by anonymous 30.07.2018 / 21:13

1 answer

0

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

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!

    
31.07.2018 / 13:11