0
Good morning!
I already checked the link, Form within Form, but that’s not what I’m looking for.
I need to know if one form inside the other with two buttons and two distinct actions works.
Example:
<form type="post" action="dados_cadastrais.php">
<form type="post" action="negocicao.php">
<input type="text" value="nome" />
<input type="submit" value="Enviar">
</form>
<input type="text" value="Parcela">
<input type="submit" value="Salvar">
</form>
Actual code of the project:
<form method="post" action="<?= base_url()?>admin/credores/adicionar" id="form_credor_adicionar">
<div class="modal-body" style="padding-bottom: 0px;"> <!--padding 0px -->
<div class="row">
<div class="form-group col-sm-4">
<label for="cnpj">CNPJ</label>
<input type="text" id="cnpj" name="cnpj" class="form-control" autocomplete="off" placeholder="000.000.000-00" value="<?php echo set_value('cnpj'); ?>" >
</div>
<div class="form-group col-sm-6">
<label for="nome">Nome</label>
<input type="text" id="nome" name="nome" class="firstname form-control" autocomplete="off" onkeyup="maiuscula('.firstname')" placeholder="Informe o nome do devedor" value="<?php echo set_value('nome'); ?>" >
</div>
<div class="form-group col-sm-2">
<label for="genero" class="control-label">Ativo</label>
<select id="genero" name="genero" class="form-control">
<option value="" selected="selected">Selecione</option>
<option value="1">Sim</option>
<option value="0">Não</option>
</select>
</div>
<div class="form-group col-sm-12" style="margin-bottom: 0px;"> <!--margem 0px -->
<div class="card card-border nav-tabs-custom">
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#dados_cadastrais" data-toggle="tab" aria-expanded="true"><i class="fa fa-user" style="color: #A4BE40"></i> Dados Cadastrais</a></li>
<li class=""><a href="#tabela_negociacao" data-toggle="tab" aria-expanded="false" ><i class="fa fa-map-marker" style="color: #E9573F"></i> Tabela de Negociação</a></li>
</ul>
<div class="tab-content" style="">
<?php include 'include/tab_adicionar_dados_cadastrais.php';?>
<?php include 'include/tab_adicionar_tabela_negociacao.php';?>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer clearfix">
<button type="submit" class="btn btn-primary btn-flat pull-left"><i class="fa fa-save"></i> Salvar</button>
<button type="button" class="btn btn-default btn-flat" onclick="limpar_campos(this.form)"><i class="fa fa-refresh"></i> Limpar</button>
<button type="button" class="btn btn-default btn-flat" data-dismiss="modal"><i class="fa fa-times"></i> Cancelar</button>
</div>
</form>
what is the need for this?
– Rafael Augusto
I have a modal that contains two tabs, Where the first tab must send registration data. And the second tab, sends negotiation data. Both tabs call different controllers and send data to right tables. Where the two tabs are called via include and are between a form.
– Wagner Fillio
I still don’t understand the need for a form within another
– Rafael Augusto
It does not work, it will only work < input type="Submit" value="Send" > in the action data_cadastrais.php
– user60252
See the code update. <? php include 'include/tab_addir_table.php';? >, this part is another form
– Wagner Fillio
No, it doesn’t work. Elements
form
cannot be nested. See here. If the forms use different controllers and send to different tables, it makes no sense that they are in the same form.– Woss
Nothing has changed, see http://kithomepage.com/sos/dois-forms.htm only the button of the form included with the action of the first form
– user60252
@Andersoncarloswoss, as soon as I separate the two form, the page ran away from the layout, there is some other way to do it ?
– Wagner Fillio
Yes, adjust your layout accordingly. Using one form within another will be gambiarra. Don’t do this.
– Woss
Thank you all!
– Wagner Fillio
To not escape the layout, you will have to work a little. Put the second form inside a div and outside the first form. With css you are able to position exactly in the desired location. I made a model, :) , see http://kithomepage.com/sos/dois-forms.htm both "save" and "send" work.
– user60252
@Leocaracciolo, I even put an example of images, to see how I’m doing! In this line: <div class="tab-content" style=""> <?php include 'include/tab_addition_data_cadastrais.php';? > <?php include 'include/tab_address_table.php';? > </div> about tab_addition_dates_cadastrais.php, all right, because you compose the same form, but tab_addition_table, is part of another form. I wanted to keep this layout
– Wagner Fillio
So, this is what I told you in the previous comment, you’ll have to put the div class="tab-content with form2 width and height. Put form2 in a div id="form2" outside of Form1. With css position the div with id=form2 on top of the div class="tab-content. That’s what I did in my model. Check the source code there.
– user60252
Maybe changing your question to how to position with css a div that contains a form within a div on the page ....
– user60252