Joomla custom form action doesn't work

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


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.

mBgl,LLEgHSS1IF1eq0 ny,f FFWP1KH17PHx9Z5EXFo,nd4AT320FfHsn1,SoN6R,cdl6xVybBPjmw,UwR0,ib9,9 ti0,Bw10RmGC
i,KaVMFXAirb0Tv012V qYhU 6Z,2AKs17Nx90gV K5BA66CBJO0lD jY3UPmq20p5wLz,4TX3lC4sex1IT WgoT EPIRk l4KB

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham