1

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 fileds 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 wich 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?

  • Importing your own version of jQuery is going to lead to all sorts of issues. I strongly suggest you dont. There's no reason to do that when you only require a mask plugin. Find a vanilla Javascript one and you'll be good to go ;) – Lodder Jul 30 '18 at 23:16
  • FYI: For stability in "next month" generation, read this page. And if you are only using $select once, don't bother declaring the variable, just echo the returned value. – mickmackusa Jul 31 '18 at 4:46
  • Thank you for your tips, @mickmackusa! I really appreciate it! – Manuela Bittencourt Jul 31 '18 at 11:08
1

Change type="button" to type="submit".

From Mozilla Documentation:

<input type="button"> elements have no default behavior (their cousins, <input type="submit"> and <input type="reset"> are used to submit and reset forms, respectively). To make buttons do anything, you have to write JavaScript code to do the work.

and

Note: While <input> elements of type "button" are still perfectly valid HTML, the newer <button> element is now the favored way to create buttons. Given that a <button>’s label text is inserted between the opening and closing tags, you can include HTML in the label, even images.

  • I can't believe it worked! I would never guess thtat! Thank you so much! – Manuela Bittencourt Jul 31 '18 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.