How to send inputs to Controller with dynamic "name"? (Codeigniter)

Asked

Viewed 23 times

0

I’m developing a quiz game, where the user has several input’s to fill.

Only that I am not able to develop the logic to perform the comparison of the entered data with the database data.

Follow the view:

   <div class="container text-center">
    <?php
        echo form_open_multipart('questionario/gabarito');
    ?>
    <?php foreach($imagens as $key=> $imagem):?>
    <div class="area-imagem position-relative">

        <div class="mb-3">
            <img src="<?php echo base_url('assets/upload/'.$imagem['caminhoImagem']) ?>" width="720" height="auto" style="border: 1px solid rgb(185, 182, 182, 185);"> 
        </div>
        <?php foreach($imagem['marcacoes'] as $key=> $marcacao):?>
            <div class="ponto" id="<?=$marcacao['idMarcacao']?>" style="top:<?=$marcacao['coordY']?>px; left:<?=$marcacao['coordX']?>px"><b></b></div>
            <div class="form-group">
                <label for="<?=$marcacao['idMarcacao']?>"><b> - </b></label>
                <input name="<?=$marcacao['idMarcacao']?>" type="text">
            </div>
        <?php endforeach;?>

    </div>
    <?php endforeach;?>
    <input type="submit" class="btn btn-primary btn-lg mb-3" value="Finalizar">
    <?php 
        echo form_close(); 
    ?>
</div>
  • Could you explain your problem better? Any errors? Expected input and output...

  • Form inputs receive as name the ID of the table row where the correct answer is. I would need to recover through the Controller each of these 'name', but as they are dynamic I am not getting. I would like to know how to pass to the Controller these "Names".

  • If you access $this->input->post/get(null) should get the list of all values passed, depending on the method set in the form, should use the get or post

No answers

Browser other questions tagged

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