Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I am using Laravel 6 to create an insert blade. When I wanted to display the view, it generated an error as shown below:
error:syntax error, unexpected end of file
With this code:
#extends('layouts.app')
#section('title','insert')
#section('content')
#if(session('message'))
<div class="">
{{session('message')}}
</div>
#endif
<br/>
<form class="" id="feedback_form" method="post" action="{{route('insert')}}">
<input type="hidden" name="_token" value="{{csrf_token()}}" />
<input type="hidden" name="id" value="" />
<div class="">
<label for="name" class=" ">Tên sản phẩm<span class=""> :</span></label>
<input type="text" name="name" class=""/>
</div>
<div class=" ">
<label for="name" class=" ">Mô tả<span class=""> :</span></label>
<input type="text" name="description" class=""/>
</div>
<div class=" ">
<label for="name" class=" ">Danh mục<span class=""> :</span></label>
<select name="cate">
#foreach($cate as $ca)
<option value="{{ $ca->id }}">{{ $ca->name }}</option>
</select>
</div>
<div class="">
<div class="">
<button class="btn btn-success" type="submit">SAVE</button>
<button class="btn btn-default" type="reset">Close</button>
</div>
</div>
</form>
#endsection
What's the problem?
Just put this code
you forgot to put #endforeach
<select name="cate">
#foreach($cate as $ca)
<option value="{{ $ca->id }}">{{ $ca->name }}</option>
#endforeach
</select>
when you write foreach in a blade file you need to end it by endforeach.same for if in blade file like endif.So here is your error for not endforeach.
Try this,
#foreach($cate as $ca)
<option value="{{ $ca->id }}">{{ $ca->name }}</option>
#endforeach
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
how can i stop the reply form from showing and repeating its self after a reply has been made
#foreach($comments as $comment)
<div class="display-comment">
<strong>{{ $comment->user->name }}</strong>
<p>{{ $comment->comment }}</p>
<form method="post" action="{{ route('reply.add') }}">
#csrf
<div class="form-group">
<input type="text" name="comment" class="form-control" />
<input type="hidden" name="post_id" value="{{ $post_id }}" />
<input type="hidden" name="comment_id" value="{{ $comment->id }}" />
</div>
<div class="form-group">
<input type="submit" class="py-0 btn btn-sm btn-outline-danger" style="font-size: 0.8em;" value="Reply" />
</div>
</form>
#include('posts.comments.reply', ['comments' => $comment->replies])
</div>
#endforeach
#forelse($comments as $comment)
<div class="display-comment">
<strong>{{ $comment->user->name }}</strong>
<p>{{ $comment->comment }}</p>
#include('posts.comments.reply', ['comments' => $comment->replies])
</div>
#empty
<div> No comments found</div>
#endforelse
<form method="post" action="{{ route('reply.add') }}">
#csrf
<div class="form-group">
<input type="text" name="comment" class="form-control" />
<input type="hidden" name="post_id" value="{{ $post_id }}" />
<input type="hidden" name="comment_id" value="{{ $comment->id }}" />
</div>
<div class="form-group">
<input type="submit" class="py-0 btn btn-sm btn-outline-danger" style="font-size: 0.8em;" value="Reply" />
</div>
</form>
You should have be able to figure it out. It's not that tricky
#if (!empty($comment->replies))
#include('posts.comments.reply', ['comments' => $comment->replies])
#empty
This is a noob question, I send a post request to my controller and all it can get is the request of the input. What I want is I can also get the value of $cat array.
Here's my blade:
#if (!$categories->isEmpty())
<form action="{{route('subcategory.store')}}" method="POST">
#csrf
<div class="row">
<div class="input-group mb-3 col-md-4">
<div class="input-group-prepend">
<label class="input-group-text" for="inputGroupSelect01">Choose Category:</label>
</div>
<select class="custom-select" id="inputGroupSelect01">
#foreach ($categories as $cat)
<option value="{{$cat->id}}">{{$cat->name}}</option>
#endforeach
</select>
</div>
<input type="text" name="subcat" id="subcat" class="form-control col-md-3 ml-5">
<button type="submit" class="btn btn-success btn-lg ml-3">Save Sub Category</button>
</div>
</form>
#endif
And here's my returned value.
{"_token":"XlzwIt2jFqcybqqSjwLLJIAChG5tui7gvHzlaeAq","subcat":"xx"}
You forgot to add name="cat" in select i guess
<select class="custom-select" id="inputGroupSelect01">
simple add name="" attr
<select class="custom-select" id="inputGroupSelect01" name="cat">
I am using laravel 5.2. Controller method store, show, and edit is working fine but update method is not working.
edit.blade is as:
#extends ('layouts.backend')
#section ('content')
<div class="pull-right">
<a class="btn btn-primary" href="{{ route('backend.index') }}"> Back</a>
</div>
<form method="PATCH" action="{{ route('backend.update', $reports->id) }}">
<div>
create report
</div>
<div>
<table>
<tr>
<td>
<div class="form-group required">
<label for="category_id" class="control-label">ID</label>
<input class="form-control" name="id" id="id" type="text" value="{{ $reports->id}}">
</div>
<div class="form-group required">
<label for="category_id" class="control-label">Category</label>
<select class="form-control" id="category" name="category"><option value="" selected="selected">Select</option><option value="1">Agriculture</option><option value="2">Food</option><option value="3">Beverage</option></select>
</div>
<div class="form-group required">
<label for="name" class="control-label">Name</label>
<input class="form-control" name="name" id="name" type="text" value="{{ $reports->name}}">
</div>
<div class="form-group required">
<label for="url" class="control-label">Url</label>
<input class="form-control" name="slug" id="slug" type="text" value="{{ $reports->slug}}">
</div>
<div class="form-group required">
<label>Brief Description</label></br>
<textarea id="brief_des" name="brief_des" rows="12" cols="70" style="width: 80%" >
{{ $reports->brief_des}}
</textarea>
</div>
<div class="form-group required">
<label>Full Description</label></br>
<textarea id="full_des" name="full_des" rows="12" cols="70" style="width: 80%">
{{ $reports->full_des}}
</textarea>
</div>
<input type="submit" value="Update"/>
</td>
<td>
</td>
</tr>
</table>
</div>
{{ Form::token() }}
</form>
#endsection
and Controller update method code is as:
public function update(Request $request, $id){
report::find($id)->update($request->all());
return redirect()->route('backend.index')
->with('success','Product Updated Successfully');
}
and route.php is as:
Route::resource('backend', 'ReportController');
when I am submitting the form then I am getting any update in my database and redirect is not working also.
Hi there I have this fields:
<form role="form" class="form margin-bottom-0" action="{{ url('/test') }}" method="post" enctype="multipart/form-data">
{{ csrf_field() }}
<div class="box box-widget widget-use padding-40 padding-top-0 box-shadow-none">
<div class="row">
<div class="col-md-6">
<div class="form-group floating-label {{ $errors->has('name') ? ' has-error' : '' }}">
<input class="form-control" name="name" id="regular2" type="text" value="#if($account){{$account['name']}} #endif" >
<label for="regular2" >#lang('payment.full_name')</label>
#if ($errors->has('name'))
<span class="help-block">
<strong>{{ $errors->first('name') }}</strong>
</span>
#endif
</div>
</div>
<div class="col-md-6">
<div class="form-group floating-label {{ $errors->has('address') ? ' has-error' : '' }}">
<input class="form-control" name="address" id="regular2" type="text" value="#if($account){{$account['address']}}#endif" >
<label for="regular2">#lang('payment.address')</label>
#if ($errors->has('address'))
<span class="help-block">
<strong>{{ $errors->first('address') }}</strong>
</span>
#endif
</div>
</div>
</div>
</div>
<button type="submit" class="btn save-lang savecard">#lang('buttons.save_changes')</button>
</form>
and when I submit it shows me the validation just fine
but when I fill one field and I submit the field that I put text on it empties, how can I make the text to stay..?
Try this on every inputs you have:
<input class="form-control" name="name" id="regular2" type="text" value="{{ old('name') }}" >
Just use old().
You can use the old method in your template referring the documentation
If you use $this->validate(/*your rules*/) in your controller, it will send the errors and the old input.
Then your can use for exemple :
<input class="form-control" name="name" id="regular2" type="text" value="{{ old('name') }}" > To make the text stay.
Hopes it helps you.
I have an issue.
I have dynamic form as per user wants.
Everything is going good except i cannot retrieve old values when validation occurs. What i want is validation message with old input values. The problem is due to dynamic form .
Here is my code :
<div class="col-sm-5">
<input class="form-control" type="text" name="key_name[]"
placeholder="Size" value="{{ old('key_name[]') }}">
</div>
<div class="col-sm-5">
<input class="form-control" type="text" name="key_value[]"
placeholder="Price" value="{{ old('key_value[]') }}">
</div>
<button type="button" class="btn btn-danger remove-field"><i
class="ion-trash-a"></i> Delete
</button>
#if ($errors->has('key_name[]'))
<div class="error-add-size-message">
<span class="help-block">
<strong> * {{ $errors->first('key_name[]') }}</strong>
</span>
</div>
#endif
Thanks in advance.
You can count form inputs in your controller and flash this count in the session.
$count = count($request->input("key_name"));
session()->flash("form_count",$count);