Joomla custom form action doesn't work

Multi tool use


Joomla custom form action doesn't work
I'm learning how to make my own module on Joomla.
MyModule mod_planejamentomensal.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');
default.php has my form (with some other fields and jQuery, I'm copying part of it here so it won't be 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, my form action above points to adicionaForm.php which is like:
<?php
defined('_JEXEC') or die;
$input = new JInput;
$teste = $input->get('mes',null);
echo "Show: "+$teste;
?>
But when I click on submit button nothing happens...I Know there must be something on Joomla that I'm doing wrong. I tried to read documentation for forms but I didn't understand much of it. Can anyone please give me a hint?
1 Answer
1
Ok, at first I thought my action address was somehow wrong. But I got the answer from another site and figure this out: my code wasn't working because of the button's input type.
So I changed it 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 just fine.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.