mardi 28 juin 2016

Laravel multiple forms with a only one submit button?

I have a form that can edit multiple areas in multiple tables, but it does not work unless I have a submit button within each form , is there any way to do this with one submit button?

    {!!Form::model($pregunta,['route'=>['seleccion.update',$pregunta->id],'method'=>'PUT','files' => true])!!}
    {!!Form::label('categoria','Categoria: ')!!}
      {!!Form::select('categorias_id', $categoria,null,['id'=>'categoriaSelSimple','class'=>'form-control',
                                            'placeholder'=>'Seleccione una opcion..','required'])!!}<br>
      {!!Form::label('subcategoria','Sub-categoria: ')!!}
      {!!Form::select('sub_categorias_id', $subcategoria,null,['id'=>'subcategoriaSelSimple','class'=>'form-control',
                                            'placeholder'=>'Seleccione una opcion..','required'])!!}<br>
    @foreach($opcion as $key => $value)
        {!!Form::model($value,['route'=>['opciones.update',$value->id],'method'=>'PUT'])!!}
        <div class="form-group option-container">
            <div class="input-group ">
              @if($value->correcto == 1)
                <span class="input-group-addon">
                  {!!Form::select('correcto[]', ['0' => 'Incorrecto','1' => 'Correcto'])!!}
                </span>
              @else
                <span class="input-group-addon">
                  {!!Form::select('correcto[]', ['1' => 'Correcto','0' => 'Incorrecto'])!!}
                </span>
              @endif
                {!!Form::text('opcion[]',$value->opcion,['class'=>'form-control']) !!}
                {{-- {!!Form::text('opcion[]',null,['class'=>'form-control', 'placeholder'=>'Ingresa una opcion..'])!!} --}}
              <span opcion-id="{{$value->id}}" class="input-group-btn">
                  <button class="btn btn-outline btn-danger btn-remove" type="button">X</button>
              </span>
            </div>
        </div>
        {{Form::close()}}
      @endforeach
                        <button type="button" class="btn btn-outline btn-success btn-lg btn-block btn-add-more-options">Agregar opción</button>
                        <h1 class="page-header"></h1>
                        {!!Form::submit('Actualizar',['class'=>'btn btn-outline btn-primary'])!!}

        </div>

    <!-- /.col-lg-8 -->
    <!-- /.col-lg-4 -->
</div>
{!!Form::close()!!}

I have multiple forms, one main and the others added through a foreach (how many depends of the table ), so i need to update these fields generated by the foreach but it doesn't work because i dont have a submit button for each form, how i can do this??

Aucun commentaire:

Enregistrer un commentaire