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??
Using only HTML, no, multiple forms cannot be submitted with a single submit button.
This could be done using a bit of JavaScript. For each form you would need to track which values had been changed, then submit those forms via AJAX.
Another thing to consider is combining all the forms into a single HTML form and let the controller->action() put the information where it belongs.
Related
I have a problem submitting a form in laravel 7. I can explain the situation:
My form label is
<form action="/boards/{{$data->id}}/send"
id="submit_form_all"
method="post" enctype=multipart/form-data>
#csrf
And inside the form, I have 3 div (It is a tab pane, I have done it with materializeCSS):
<div id="configPrincipalipal" class="col s12 ">
...
</div>
<div id="controAcceso" class="col s12 controAccesoDiv">
...
</div>
<div id="agendaConf" class="col s12 agendaConfDiv " style="margin-bottom:10%">
...
</div>
And after that, I have 2 buttons:
<button class="btn waves-effect waves-light offset-s6 red" href="#" name="action">
{{Lang ::get('agendaContactos.backButt')}}
<i class="material-icons left">arrow_back</i>
</button>
<button onclick="submit_form()" class="btn waves-effect waves-light offset-s6 blue" name="action" >
{{Lang ::get('agendaContactos.subButt')}}
<i class="material-icons right">send</i>
</button>
I tried with input type="submit" / button type="submit" and this example is with a function submit_form() ->
function submit_form() {
console.log("sending");
$("#submit_form_all").submit();
}
I can see the sending text, so the button arrives to the function.
If I put the button just after the 1st div with id configPrincipal, then I arrive to controller, but if I put the button after that (for example 1 line after opening the second div), the form is not submitted and it do not anything, I got no response on the console either.
This is an image of the website:
The code below is used to show all plans. As you can see there is a SELECT plan option. I want for any plan when I click on SELECT it should pass its ID to the second field.
I used $request->gate->id but it did not work in my Blade file.
#foreach($pack as $gate)
<div>
<p style="color: #000">Amount: {{$gate->min_amount}} {{$general->symbol}} -
</div>
<div class="panel-footer">
<button class="btn btn-primary btn-block">SELECT</button>
</div>
#endforeach
{{csrf_field()}}
<input type="text" name="package_id" value="{{$gate->id}}"> // I want to Transfer here when click on select.
You need to use some jQuery code to set the gate id as the value of the input field with the name package_id
Try this:
#foreach($pack as $gate)
<div>
<p style="color: #000">Amount: {{$gate->min_amount}} {{$general->symbol}}
</div>
<div class="panel-footer">
<button class="btn btn-primary btn-block" data-gate-id="{{$gate->id}}">SELECT</button>
</div>
#endforeach
<input type="text" name="package_id" value="">
Use this jQuery code on the same page:
$('.btn-block').on('click', function() {
var gate_id = $(this).data('gate-id'); // get gate id from button custom attribute data-gate-id on click
$("input[name='package_id']").val(gate_id); // set gate id in input field
});
When I select a class from in my view and click on Genrate, I try to retrieve the value of the selected class but I am not able to get the value of the class selected.
When I return $condition, it returns empty. In the url after submitting, it shows like http://localhost:8000/generate/timetable?class=
Why is this happening?
<div class="row">
<div class="col-xl-4 col-lg-12 col-md-12 mb-1">
<fieldset class="form-group">
<label for="squareText">Type</label>
{{ Form::select('class',$classes,$selectedClass,['class'=>'form-control','required'=>'true'])}}
<br>
<button class="btn btn-primary pull-left square" type="submit"><i class="glyphicon glyphicon-th"></i> Generate</button>
</fieldset>
</div>
</div>
Controller
$condition = Input::get('class');
if (!isset($condition['class']))
$condition['class'] = 0;
$courses = $course->where('class',$condition)->get()->toArray();
return $condition;
Your button is inside a link:
<a href="/generate/timetable?class={{ request('class') }}">
<button class="btn btn-primary pull-left square" type="submit"> ... </button>
</a>
Clicking it is actually clicking the <a href> link, not clicking the button and submitting the form. So instead of submitting the form, you are simply browsing to the URL the the link points to.
It isn't clear from your question what the link is there for, but if clicking the button is supposed to submit the form, you probably want to put your form elements inside an actual <form>.
It looks like you're using Laravel Collective ({{ Form::select('class .... looks like that), so see those docs on how to open a form:
{!! Form::open(['url' => '/generate/timetable?class=' . request('class')]) !!}
{{ Form::select('class' .... }}
<button class="btn btn-primary pull-left square" type="submit"> ... </button>
{!! Form::close() !!}
You'll probalby also need to add a CSRF token, it is also described in the Laravel Collective docs, as well as in the Laravel docs.
I'm trying to resize a form box using .col-md-12. It works fine if I keep the code inside the span tag as it is, but if I take it off (and I want to, because I need to remove that button) it stops working. In this scenario the form box will maintain some kind of default size, no matter which value is inserted after -md.
Could anyone give some help? If it matters, this HTML file is part of the viewer of a project using laravel framework.
<div class="box-body">
<div class="col-md-12">
<div class="form-group">
<label for="name">{{ 'name' }}</label>
<div class="input-group">
<input class="form-control" type="text" name="name" value="{{ $name }}">
<span class="input-group-btn">
<a class="btn btn-warning" href="{{ url('path', $id) }}" title="{{ 'edit' }}"><i class="fa fa-pencil"></i></a>
</span>
</div>
</div>
</div>
</div>
Provided that I understood your question right, just add the btn class to the span tag and remove the a tag.
<span class="input-group-btn btn">
<!-- removed button -->
</span>
<input type="button" class="btn btn-primary btn-lg btn-block" value="(AAP)" data-toggle="modal" href="#teklif{$foo}">
I want to send foo value.
foo == number
like 0,1,2..
<div id="teklif" class="chat_modal modal fade hide">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">x</button>
</div>
<div class="modal-body">
<section class="welly form_align">
<br/>
<br/>
<span id="status"> {$foo}</span>
<br/>
</section>
</div>
<div class="modal-footer">
<span id="statusteklifc"></span>
</div>
</div>
How to send value to modal ? and i sended value smarty variable.
i want to equal value:
<span id="status"> {$foo} == 2</span>
i wan to make it.
modal is simply part of your DOM so You can change it simply:
$('#status').html(any_variable);
But You need add some information when do You want to send this value.
If You want to read value from button when modal is displayed You can:
$('#teklif').on('shown.bs.modal', function (e) {
$('#status').html($('#button_ID').html());
});