Problems submitting a multiple select in codeigniter in php

0

I have this select multiple in html that is without anything and add items at the click of a button.

<div class="row">
     <div class="form-group col-md-12">
          <?php
              echo form_label('Para Vincular:', 'lstParaVincular');
              echo form_multiselect('lstParaVincular[]', '', '', 
              array('class' => 'form-control', 'id' => 'lstParaVincular'));
          ?>                                    
     </div>
</div>

When I submit the form, var_dump of lstParaVincular is displaying NULL

Code of controller :

$lstParaVincular = $this->input->post('lstParaVincular');
var_dump($lstParaVincular);

Button code to add in select :

btnAdicionar.on('click', function() {       
    lstParaVincular.append($('<option>', {value: 1, text: 'Teste'}));
});

It is adding without problem on the button, the problem is when I submit lstParaVincular , it is displaying NULL in var_dump

Edit: What I need is to send all values of form_multiselect to the server, by post , indepentende if it is selected or not.

Is it possible?

    
asked by anonymous 31.10.2018 / 19:15

0 answers