I have this code :
{{ form_start(form, {'attr': {'class': 'form-vertical edit-form', 'id': 'new-users-form', 'data-view': 'new'}}) }}
<div class="row">
<div class="field-group col-xs-12 col-sm-4">
<div class="box box-default">
<div class="box-body " id="box-body-_easyadmin_form_design_element_0">
<div class="row">
<div class="col-xs-12 ">
<div class="form-group field-text">
{{ form_row(form.value, {'attr': {'class': 'form-control' }}) }}
</div>
</div>
<div class="col-xs-12 ">
<div class="form-group field-text">
{{ form_row(form.comment, {'attr': {'class': 'form-control' }}) }}
</div>
</div>
<div class="col-xs-12 form-actions">
<div class="form-group">
<div id="form-actions-row">
<button type="submit" class="btn btn-primary action-save pull-right">
<i class="fa fa-check"></i> {{ 'general.buttons.confirm'|trans }}
</button>
<a class="btn btn-danger pull-right action-delete" style="margin-right: 1%" title=""
href="{{ path('admin', {'entity' : 'User', 'action' : 'delete', 'id' : entity.id}) }}" target="_self">
<i class="fa fa-trash-o"></i>
{{ 'general.buttons.delete'|trans }}
</a>
<a name="list" class="btn btn-secondary pull-right" title=""
href="{{ path('admin', {'entity' : 'User', 'action' : 'list'}) }}" target="_self">
{{ 'general.buttons.back_to_liste'|trans }}
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{{ form_widget(form._token) }}
{{ form_end(form,{'render_rest': false}) }}
Add and Back links works just fine. The only problem is with delete button. When I try to delete I'm redirect to the liste of User entity whitout delete the current User. I don't have any errors. Please help me. Thx in advance
Related
In my laravel application, I have a view to edit my non-admin users (participants) (via admin dashboard).
In this application, each user can add a pet too.
Once an admin goes to a certain participant's profile admin should be able to edit the participant and also the pet info as well if needed.
For that, I have to use two forms, one to update the user and another to update the pet. But both the forms are in a single view.
I've already created the participant controller (ParticipantController) and tested all the methods are working fine.
For the pets too I created a different model and a controller(PetsController).
But now I'm struggling to connect my pets controller to the participant edit blade.
following is the routing for the relevant scenario in my web.php
Route::group(['middleware' => ['auth']], function() {
Route::resource('/admins/roles','Admin\RoleController');
Route::resource('/admins/users','Admin\UserController');
Route::resource('/admins/participants','Admin\ParticipantController');
});
I've already created the participant's edit form which works properly and looking for some help to adding the petscontroller to the same blade.
following is my participants edit blade
#extends('layouts.admin')
#section('content')
<div class="row">
<div class="col-md-9">
<h2 class="view-title">{{ __('Edit User') }}</h2>
</div>
<div class="col-md-3">
<div class="text-left">
<!-- <a class="btn btn-primary btn-admin" href="{{ route('users.index') }}"> {{ __('Back') }}</a> -->
</div>
</div>
</div>
#if ($message = Session::get('success'))
<div class="alert alert-success">
<a class="close" onclick="jQuery('.alert').hide()">×</a>
<p>{{ $message }}</p>
</div>
#endif
<div class="row">
<div class="col-md-12" mt-5>
#if (count($errors) > 0)
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
</div>
#endif
</div>
</div>
{!! Form::model($user, ['method' => 'PATCH','enctype'=>'multipart/form-data','route' => ['participants.update', $user->id]]) !!}
<div class="row">
<div class="col-md-3 mt-5">
<!-- #if($user->image_id != 'default-avatar.png')
<button type="submit" name="resetphoto" class="btn btn-danger px-3 mr-5 pull-right"><i class="fa fa-trash" aria-hidden="true"></i>
</button>
#endif
-->
#if(empty($user->image_id))
<center> <img src="/propics/default-avatar.png" alt="Profile Pic" id="profile_pic_display_settings" class="mb-3"></center>
</p>
#else
<center> <img src="/propics/{{$user->image_id}}" alt="Profile Pic" id="profile_pic_display_settings" class="mb-3"></center>
#endif
<center><label for="propic" class="btn btn-default subscribe"><i class="fas fa-camera"></i></label></center>
<input id="propic" type="file" name="image_id" class="form-control">
<label id="file_name"></label>
#error('propic')
<span class="help-block" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<div class="col-md-9 mt-5">
<div class="form-group row">
<div class="col-md-6">
{!! Form::text('first_name', null, array('placeholder' => 'First Name','class' => 'form-control txt_txt')) !!}
{!! $errors->first('first_name', '<span class="help-block" role="alert">:message</span>') !!}
</div>
<div class="col-md-6">
{!! Form::text('last_name', null, array('placeholder' => 'Last Name','class' => 'form-control txt_txt')) !!}
{!! $errors->first('last_name', '<span class="help-block" role="alert">:message</span>') !!}
</div>
</div>
<div class="form-group row">
<div class="col-md-6 ">
{!! Form::text('email', null, array('placeholder' => 'Email','class' => 'form-control txt_txt')) !!}
{!! $errors->first('email', '<span class="help-block" role="alert">:message</span>') !!}
</div>
<div class="col-md-6 ">
{!! Form::password('password', array('placeholder' => 'Password','class' => 'form-control txt_txt')) !!}
{!! $errors->first('password', '<span class="help-block" role="alert">:message</span>') !!}
</div>
</div>
<div class="form-group row">
<div class="col-md-6 ">
{!! Form::password('confirm-password', array('placeholder' => 'Confirm Password','class' => 'form-control txt_txt')) !!}
</div>
<div class="col-md-6">
{!! Form::select('roles[]', $roles,$userRole, array('class' => 'form-control','multiple')) !!}
{!! $errors->first('roles', '<span class="help-block" role="alert">:message</span>') !!}
{!! Form::text('role_id','null', array('class' => 'form-control txt_none')) !!}
{!! Form::text('gender','null', array('class' => 'form-control txt_none')) !!}
</div>
</div>
<div class="col-md-12 text-right px-0 ">
<a class="btn btn-primary btn-admin-form-cancel mt-5" href="{{ route('participants.index') }}"> {{ __('Cancel') }}</a>
<button type="submit" class="btn btn-primary btn-admin-form-save mt-5">{{ __('Save') }}</button>
</div>
</div>
</div>
{!! Form::close() !!}
<div class="row">
<hr class="black_line">
</div>
{!! Form::model($user, ['method' => 'PATCH','enctype'=>'multipart/form-data','route' => ['participants.update', $user->id]]) !!}
<div class="row">
<div class="col-md-3 mt-5">
<!-- #if($user->image_id != 'default-avatar.png')
<button type="submit" name="resetphoto" class="btn btn-danger px-3 mr-5 pull-right"><i class="fa fa-trash" aria-hidden="true"></i>
</button>
#endif
-->
#if(empty($user->image_id))
<center> <img src="/propics/default-avatar.png" alt="Profile Pic" id="profile_pic_display_settings" class="mb-3"></center>
</p>
#else
<center> <img src="/propics/{{$user->image_id}}" alt="Profile Pic" id="profile_pic_display_settings" class="mb-3"></center>
#endif
<center><label for="propic" class="btn btn-default subscribe"><i class="fas fa-camera"></i></label></center>
<input id="propic" type="file" name="image_id" class="form-control">
<label id="file_name"></label>
#error('propic')
<span class="help-block" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<div class="col-md-9 mt-5">
<div class="form-group row">
<div class="col-md-6">
{!! Form::text('first_name', null, array('placeholder' => 'Pet Name','class' => 'form-control txt_txt')) !!}
{!! $errors->first('first_name', '<span class="help-block" role="alert">:message</span>') !!}
</div>
<div class="col-md-6">
{!! Form::text('pet_age', null, array('placeholder' => 'Pet Age','class' => 'form-control txt_txt')) !!}
{!! $errors->first('pet_age', '<span class="help-block" role="alert">:message</span>') !!}
</div>
</div>
<div class="col-md-12 text-right px-0 ">
<a class="btn btn-primary btn-admin-form-cancel mt-5" href="{{ route('participants.index') }}"> {{ __('Cancel') }}</a>
<button type="submit" class="btn btn-primary btn-admin-form-save mt-5">{{ __('Save') }}</button>
</div>
</div>
</div>
{!! Form::close() !!}
#endsection
{!! view_render_event('bagisto.shop.layout.header.account-item.before') !!}
<login-header></login-header>
{!! view_render_event('bagisto.shop.layout.header.account-item.after') !!}
<script type="text/x-template" id="login-header-template">
<div class="dropdown">
<div id="account">
<div class="welcome-content pull-right" #click="togglePopup">
<i class="material-icons align-vertical-top">perm_identity</i>
<span class="text-center">
#guest('customer')
{{ __('velocity::app.header.welcome-message', ['customer_name' => trans('velocity::app.header.guest')]) }}!
#endguest
#auth('customer')
{{ __('velocity::app.header.welcome-message', ['customer_name' => auth()->guard('customer')->user()->first_name]) }}
#endauth
</span>
<span class="select-icon rango-arrow-down"></span>
</div>
</div>
<div class="account-modal sensitive-modal hide mt5">
<!--Content-->
#guest('customer')
<div class="modal-content">
<!--Header-->
<div class="modal-header no-border pb0">
<label class="fs18 grey">{{ __('shop::app.header.title') }}</label>
<button type="button" class="close disable-box-shadow" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true" class="white-text fs20" #click="togglePopup">×</span>
</button>
</div>
<!--Body-->
<div class="pl10 fs14">
<p>{{ __('shop::app.header.dropdown-text') }}</p>
</div>
<!--Footer-->
<div class="modal-footer">
<div>
<a href="{{ route('customer.session.index') }}">
<button
type="button"
class="theme-btn fs14 fw6">
{{ __('shop::app.header.sign-in') }}
</button>
</a>
</div>
<div>
<a href="{{ route('customer.register.index') }}">
<button
type="button"
class="theme-btn fs14 fw6">
{{ __('shop::app.header.sign-up') }}
</button>
</a>
</div>
</div>
</div>
#endguest
#auth('customer')
<div class="modal-content customer-options">
<div class="customer-session">
<label class="">
{{ auth()->guard('customer')->user()->first_name }}
</label>
</div>
<ul type="none">
<li>
{{ __('shop::app.header.profile') }}
</li>
<li>
{{ __('velocity::app.shop.general.orders') }}
</li>
<li>
{{ __('shop::app.header.wishlist') }}
</li>
<li>
{{ __('velocity::app.customer.compare.text') }}
</li>
<li>
{{ __('shop::app.header.logout') }}
</li>
</ul>
</div>
#endauth
<!--/.Content-->
</div>
</div>
</script>
#push('scripts')
<script type="text/javascript">
Vue.component('login-header', {
template: '#login-header-template',
methods: {
togglePopup: function (event) {
let accountModal = this.$el.querySelector('.account-modal');
let modal = $('#cart-modal-content')[0];
if (modal)
modal.classList.add('hide');
accountModal.classList.toggle('hide');
event.stopPropagation();
}
}
})
</script>
#endpush
I have a php file for creating login page
it look like this page view
how to add a new login button like login with google by editing in it.
Please be detail while giving your answer, it is very helpful for those who are new in php.
It is better to provide general answers that is helpful for those who are working in other domain related to php.
This code belong to bagisto framework which is base on laravel.Bagisto is greate framework for creating ecommerce sites.
This is the repo of bagisto https://github.com/bagisto/bagisto.git
I am new to stackoverflow so feel free to improve my question for more clarity friends if need.
We have added social login in our master branch, you may take a pull from there. Below is the provided PR link
https://github.com/bagisto/bagisto/pull/3367
PS - as the user asked the questions regarding the platform bagisto that's why I am answering for that purpose.
I'm building a blog to learn Laravel (5.4.13). In my posts show view I'm looping through all the corresponding post comments. Beside each comment is an edit button and a delete button. For comment editing, I'm attempting to use a modal instead of redirecting to the typical edit view. Currently I'm storing the specific comment data within two data-attributes, and then retrieving those values using jQuery. Then I'm using jQuery again to pass the data into the modal. This is working fine except I'm not sure how to pass the $comment->id into the form route. Any help is much appreciated.
#extends('main')
#section('title', 'View Post')
#section('content')
<div class="row">
<div class="col-md-8">
<h1>{{$post->title}}</h1>
<small>Published: <i class="fa fa-clock-o"></i> {{ $post->created_at->format('M Y, h:i a') }}</small>
<hr class="light-hr">
<p class="lead">{{ str_limit($post->body, $limit = 200, $end = '...') }}</p>
<hr>
<div class="tags">
#foreach($post->tags as $tag)
<span class="label">
{{ $tag->name }}
</span>
#endforeach
</div>
<br>
<br>
{{-- Display comments associated with posts --}}
<h4>Related Posts <i class="fa fa-level-down"></i></h4>
#foreach($post->comments as $comment)
<?php $avatars = array('monsterid', 'identicon', 'wavatar', 'retro'); ?>
<?php $randAvatars = urlencode($avatars[array_rand($avatars)]); ?>
<div class="comments">
<div class="author-info">
<div class="author-img">
<img src={{"https://www.gravatar.com/avatar/".md5(strtolower(trim($comment->email)))."?s=55&d=".$randAvatars}} class="img-circle" alt="user profile image">
</div>
<div class="author-meta">
<b>{{$comment->name}}</b>
made a post.
<h6>Published: <i class="fa fa-clock-o"></i> {{ $comment->created_at->format('M Y, h:i a') }}</h6>
</div>
<div class="comment-controls pull-right">
<button
type="button"
class="btn btn-primary btn-sm fa fa-pencil edit-comment"
data-toggle="modal"
data-comment="{{$comment->comment}}"
data-comment-id="{{$comment->id}}"
data-target="#editComment">
</button>
<button type="button" class="btn btn-danger btn-sm fa fa-trash"></button>
</div>
</div>
<div class="author-comment">
<hr>
<p>{{$comment->comment}}</p>
</div>
</div>
#endforeach
</div>
<div class="col-md-4">
<div class="well">
<dl class="dl-horizontal">
<dt>Created: </dt>
<dd> {{ $post->created_at->format('M jS, Y') }}</dd>
<dd><i class="fa fa-clock-o"></i> {{ $post->created_at->format('h:i:s a') }}</dd>
</dl>
<dl class="dl-horizontal">
<dt>Last Updated: </dt>
<dd>{{ $post->updated_at->format('M jS, Y') }}</dd>
<dd><i class="fa fa-clock-o"></i> {{ $post->updated_at->format('h:i:s a') }}</dd>
</dl>
<dl class="dl-horizontal">
<dt>Post Slug: </dt>
<dd>{{ url('blog/'.$post->slug) }}</dd>
</dl>
<dl class="dl-horizontal">
<dt>Category: </dt>
<dd>{{ $post->category->name }}</a></dd>
</dl>
<hr>
<div class="row">
<div class="col-sm-6">
Edit
</div>
<div class="col-sm-6">
<form action="{{ route('posts.destroy', $post->id) }}" method="POST">
<input type="submit" value="Delete" class="btn btn-danger btn-block">
<input type="hidden" name="_token" value="{{ Session::token() }}">
{{ method_field('DELETE') }}
</form>
</div>
<div class="col-sm-12">
Back to <i class="fa fa-long-arrow-right" aria-hidden="true"></i> Posts
</div>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="editComment" tabindex="-1" role="dialog" aria-labelledby="editCommentLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="editCommentLabel">Edit Comment</h4>
</div>
<div class="modal-body">
<form action="{{route('comments.update', $comment->id)}}" method="POST">
<div class="modal-body">
<div class="form-group">
<textarea name="comment" class="form-control current-comment"></textarea>
<span class="test"></span>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<input type="submit" value="Save Changes" class="btn btn-primary">
<input type="hidden" name="_token" value="{{ Session::token() }}">
{{ method_field('PUT') }}
</div>
</form>
</div>
</div>
</div>
</div>
#section('scripts')
<script>
$('.edit-comment').on('mousedown', function(){
var comment = $(this).attr('data-comment');
var comment_id = $(this).attr('data-comment-id');
$('.current-comment').html(comment);
$('.test').html(comment_id);
});
</script>
#endsection
#endsection
// Comments Routes
Route::post('comments/{id}', ['uses' => 'CommentsController#store', 'as' => 'comments.store']);
Route::put('comments/{id}', ['uses' => 'CommentsController#update', 'as' => 'comments.update']);
You're almost there. I would suggest that you don't need to pass the {id} since you use the [PUT] method to pass the data in your {form}.
We can set a new hidden {input} type inside your {form} (e.g input[name="edit_comment_id"]) and remove the request parameter from the url in your form's {action} attribute.
Like this:
<form action="{{route('comments.update')}}" method="POST" id="update-comment">
<div class="modal-body">
<div class="form-group">
<input type="hidden" name="edit_comment_id" /> //place the {id} in here
<textarea name="comment" class="form-control current-comment"></textarea>
<span class="test"></span>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<input type="submit" value="Save Changes" class="btn btn-primary">
<input type="hidden" name="_token" value="{{ Session::token() }}">
{{ method_field('PUT') }}
</div>
</form>
Then in your {scripts} section:
$('.edit-comment').on('mousedown', function(){
var comment = $(this).attr('data-comment');
var comment_id = $(this).attr('data-comment-id'); // (e.g 12)
var oFormUpdateComment = $('#update-comment'); //add an {id} attribute on your form name 'update-comment' as given above.
oFormUpdateComment.find('input[name="edit_comment_id"]').val(comment_id);
});
And since we didn't pass a request parameter next to the 'comments' url anymore, You will update your [routes.php] like this:
Route::post('comments', ['uses' => 'CommentsController#store', 'as' => 'comments.store']);
Route::put('comments', ['uses' => 'CommentsController#update', 'as' => 'comments.update']);
Then in your [CommentsController], Since you already know how to get those values:
use Illuminate\Support\Facades\Input;
class CommentsController extends Controller
{
protected function store()
{
print_r('<pre>');
var_dump(Input::get('edit_comment_id'));
}
protected function update()
{
print_r('<pre>');
var_dump(Input::all());
}
}
Hope this helps for your case.
I was reluctant to answer this myself but was able to get it to work after rethinking my approach. Instead of trying to alter the blade url in the form somehow, I left the action attribute blank and built the url dynamically when the event fired. So as I did before, I grabbed the data from the data attributes, but instead of trying to alter the blade tag in the form, the url is built and then added to the action attribute. This thread was a great help. I posted my updated code incase it helps anyone.
#extends('main')
#section('title', 'View Post')
#section('content')
<div class="row">
<div class="col-md-8">
<h1>{{$post->title}}</h1>
<small>Published: <i class="fa fa-clock-o"></i> {{ $post->created_at->format('M Y, h:i a') }}</small>
<hr class="light-hr">
<p class="lead">{{ str_limit($post->body, $limit = 200, $end = '...') }}</p>
<hr>
<div class="tags">
#foreach($post->tags as $tag)
<span class="label">
{{ $tag->name }}
</span>
#endforeach
</div>
<br>
<br>
{{-- Display comments associated with posts --}}
<h4>Related Posts <i class="fa fa-level-down"></i></h4>
#foreach($post->comments as $comment)
<?php $avatars = array('monsterid', 'identicon', 'wavatar', 'retro'); ?>
<?php $randAvatars = urlencode($avatars[array_rand($avatars)]); ?>
<div class="comments">
<div class="author-info">
<div class="author-img">
<img src={{"https://www.gravatar.com/avatar/".md5(strtolower(trim($comment->email)))."?s=55&d=".$randAvatars}} class="img-circle" alt="user profile image">
</div>
<div class="author-meta">
<b>{{$comment->name}}</b>
made a post.
<h6>Published: <i class="fa fa-clock-o"></i> {{ $comment->created_at->format('M Y, h:i a') }}</h6>
</div>
<div class="comment-controls pull-right">
{{-- Store comment specific data to built URL for modal --}}
<button
type="button"
class="btn btn-primary btn-sm fa fa-pencil edit-comment"
data-toggle="modal"
data-comment="{{$comment->comment}}"
data-comment-id="{{$comment->id}}"
data-target="#editComment">
</button>
<button type="button" class="btn btn-danger btn-sm fa fa-trash" ></button>
</div>
</div>
<div class="author-comment">
<hr>
<p>{{$comment->comment}}</p>
</div>
</div>
#endforeach
</div>
<div class="col-md-4">
<div class="well">
<dl class="dl-horizontal">
<dt>Created: </dt>
<dd> {{ $post->created_at->format('M jS, Y') }}</dd>
<dd><i class="fa fa-clock-o"></i> {{ $post->created_at->format('h:i:s a') }}</dd>
</dl>
<dl class="dl-horizontal">
<dt>Last Updated: </dt>
<dd>{{ $post->updated_at->format('M jS, Y') }}</dd>
<dd><i class="fa fa-clock-o"></i> {{ $post->updated_at->format('h:i:s a') }}</dd>
</dl>
<dl class="dl-horizontal">
<dt>Post Slug: </dt>
<dd>{{ url('blog/'.$post->slug) }}</dd>
</dl>
<dl class="dl-horizontal">
<dt>Category: </dt>
<dd>{{ $post->category->name }}</a></dd>
</dl>
<hr>
<div class="row">
<div class="col-sm-6">
Edit
</div>
<div class="col-sm-6">
<form action="{{ route('posts.destroy', $post->id) }}" method="POST">
<input type="submit" value="Delete" class="btn btn-danger btn-block">
<input type="hidden" name="_token" value="{{ Session::token() }}">
{{ method_field('DELETE') }}
</form>
</div>
<div class="col-sm-12">
Back to <i class="fa fa-long-arrow-right" aria-hidden="true"></i> Posts
</div>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="editComment" tabindex="-1" role="dialog" aria-labelledby="editCommentLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="editCommentLabel">Edit Comment</h4>
</div>
<div class="modal-body">
<form id="comment-edit-modal" action="" method="POST">
<div class="modal-body">
<div class="form-group">
<textarea name="comment" class="form-control current-comment"></textarea>
<span class="test"></span>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<input type="submit" value="Save Changes" class="btn btn-primary">
<input type="hidden" name="_token" value="{{ Session::token() }}">
{{ method_field('PUT') }}
</div>
</form>
</div>
</div>
</div>
</div>
#section('scripts')
<script>
$('.edit-comment').on('mousedown', function(){
var comment = $(this).attr('data-comment');
$('.current-comment').html(comment);
var comment_id = $(this).attr('data-comment-id');
var form = $('#comment-edit-modal')
// Set current URL
var comment_edit_URL = {!! json_encode(url('/comments')) !!} + '/' + comment_id;
// Append currrent URL
form.attr('action', comment_edit_URL);
});
</script>
#endsection
#endsection
I have created a view that shows 2 columns on medium and large screens but only 1 column on small and extra small screens. I'm using the push and pull classes from bootstrap to reorder my panels at different screen sizes.
My problem is that on small and extra small screen sizes some of my links and buttons are not clickable.
I have followed this thread Links in bootstrap grid stop working in small screen mode. It says the problem is that the links are floated, resulting in a height of 0 for the parent container.
I have tried using the "clearfix" class. I've also created my own class using overflow:auto and another using overflow:hidden and none of these work.
I have never had this problem before but this is the first time I've used push/pull. Would you take a look at my code and see if you can spot the problem?
<div class="container">
<!--*********************************Modal for notes**********************************************************-->
<div class="modal fade" id="myModal" name="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h3 class="modal-title" id="myModalLabel">Notes</h3>
</div>
<div class="modal-body">
<form method="post" action="/notes/save" role="form" name="new_note">
{!! csrf_field() !!}
<div class="form-group">
<label for="note">Type a new note for this client. (The current date will be automatically added.)</label>
<textarea class="form-control" rows="15" name="note" id="note" required></textarea>
<input type="hidden" name="ind_id" value="{{ $id }}">
<input type="hidden" name="timestamp" id="timestamp">
</div>
</div>
<div class="modal-footer">
<input type="submit" class="btn btn-primary" value="Save Changes" onclick="this.form.timestamp.value=Date.now()">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</form>
</div>
</div>
</div>
</div>
<!--***********************************End modal code***********************************************************-->
<div class="row">
<div class="col-md-8 col-md-push-4 col-lg-9 col-lg-push-3">
<!--************************************Name and Address********************************************************-->
<div class="panel panel-primary">
<div class="panel-heading">Name and Address</div>
<div class="panel-body">
<address class="col-md-6">
<strong>{{ $ind->name }}</strong><br>
#if ($ind->MailingStreet)
{{ $ind->MailingStreet }}<br>
#endif
#if ($ind->MailingCity || $ind->MailingState || $ind->MailingPostalCode)
{{ $ind->MailingCity . ", " . $ind->MailingState . " " . $ind->MailingPostalCode }}
#endif
</address>
<address class="col-md-6">
#if ($ind->OtherStreet || $ind->OtherCity || $ind->OtherState || $ind->OtherPostalCode)
<strong>Other Address</strong><br>
#endif
#if ($ind->OtherStreet)
{{ $ind->OtherStreet }}<br>
#endif
#if ($ind->OtherCity || $ind->OtherState || $ind->OtherPostalCode)
{{ $ind->OtherCity . ", " . $ind->OtherState . " " . $ind->OtherPostalCode }}
#endif
</address>
</div>
</div>
<!--*******************************************End Name and Address***************************************-->
<!--*******************************************Contact Info***********************************************-->
<div class="panel panel-danger">
<div class="panel-heading">Contact Info</div>
<div class="panel-body">
#if ($ind->Cell_Phone)
<div class="col-md-5 col-sm-6"><strong>Cell Phone</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Cell_Phone }}</div>
#endif
#if ($ind->Spouse_Cell_Phone)
<div class="col-md-5 col-sm-6"><strong>Spouse Cell Phone</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Spouse_Cell_Phone }}</div>
#endif
#if ($ind->Business_Phone)
<div class="col-md-5 col-sm-6"><strong>Business Phone</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Business_Phone }}</div>
#endif
#if ($ind->Spouse_Business_Phone)
<div class="col-md-5 col-sm-6"><strong>Spouse Business Phone</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Spouse_Business_Phone }}</div>
#endif
#if ($ind->HomePhone)
<div class="col-md-5 col-sm-6"><strong>Home Phone</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->HomePhone }}</div>
#endif
#if ($ind->Fax)
<div class="col-md-5 col-sm-6"><strong>Fax</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Fax }}</div>
#endif
#if ($ind->Email)
<div class="col-md-5 col-sm-6"><strong>Email</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Email }}</div>
#endif
#if ($ind->Spouse_Email)
<div class="col-md-5 col-sm-6"><strong>Spouse Email</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Spouse_Email }}</div>
#endif
#if ($ind->Return_Type)
<div class="col-md-5 col-sm-6"><strong>Return Type</strong></div>
<div class="col-md-7 col-sm-6">{{ $ind->Return_Type }}</div>
#endif
</div>
</div>
<!--*********************************************End Contact Info******************************************-->
</div>
<div class="col-sm-12 col-md-4 col-md-pull-8 col-lg-3 col-lg-pull-9 pull-right">
<!--*******************************************Options***********************************************************-->
<ul class="list-group">
<li class="list-group-item">
<i class="fa fa-pencil-square-o"></i> Edit Client
</li>
<li class="list-group-item">
<i class="fa fa-times"></i> Delete Client
</li>
<li class="list-group-item">
<button type="button" class="btn btn-success btn-block no-print" data-toggle="modal" data-target="#myModal"><i class="fa fa-sticky-note-o"></i> Add Note</button>
</li>
<!--********************Link Form*****************************************-->
<li class="list-group-item">
<form action="/links/save" method="post" class="form-inline">
{!! csrf_field() !!}
<div class="input-group btn-block">
<input id="autocomplete" type="text" class="form-control autocomplete no-print" name="client" placeholder="Add link..." required>
<input id="autocomplete-value" type="hidden" name="autocomplete-value" class="autocomplete-value">
<input id="ind_id" name="ind_id" type="hidden" value="{{ $id }}">
<span class="input-group-btn">
<button type="submit" class="btn btn-success no-print" style="height:36px;">Go</button>
</span>
</div>
</form>
</li>
<!--***********************End Link form*************************************-->
</ul>
<!--***************************************End Options*********************************************************-->
<!--************************************************Routing sheet starts here*********************************************************-->
#if(isset($routing_sheet))
<div class="panel panel-info" id="2015_routing_sheet">
<div class="panel-heading" role="tab" id="headingOne">2015 Tax Return</div>
<ul class="list-group">
#foreach($routing_sheet as $r)
<form action='/individuals/tax_return_2015' method='post'>
{!! csrf_field() !!}
#if($r->user_name)
<li class="list-group-item" style="padding: 5px 5px 5px 5px;">
<div>
<button
type='submit'
class='btn btn-success btn-xs'
name='button'
value="Clear"
onclick="return confirm('Are you sure you want to clear this event?')">
<i class="fa fa-check" aria-hidden="true"></i>
</button>
<strong>{{ $r->name }}</strong>
</div>
<div>
{{ $r->user_name }}
{{ $r->date ? date('m/d/Y h:i a', strtotime($r->date)) : '' }}
</div>
<input type='hidden' name='routing_events_id' id='routing_events_id' value='{{ $r->id }}'>
<input type='hidden' name='routing_data_id' id='routing_data_id' value='{{ $r->routing_data_id }}'>
</li>
#else
<li class="list-group-item" style="padding: 5px 5px 5px 5px;">
<button
type='submit'
class='btn btn-danger btn-xs'
name='button'
value="Done"
onclick='this.form.timestamp.value=Date.now()'>
<i class="fa fa-square-o" aria-hidden="true"></i>
</button>
<strong>{{ $r->name }}</strong>
{{ $r->user_name }}
{{ $r->date ? date('m/d/Y h:i a', strtotime($r->date)) : '' }}
<input type='hidden' name='routing_events_id' id='routing_events_id' value='{{ $r->id }}'>
<input type='hidden' name='routing_data_id' id='routing_data_id' value='{{ $r->routing_data_id }}'>
</li>
#endif
<input id="ind_id" name="ind_id" type="hidden" value="{{ $id }}">
<input type="hidden" name="timestamp" id="timestamp">
</form>
#endforeach
</ul>
</div>
#endif
<!--*********************************************Routing Sheet ends here***********************************************-->
</div>
<div class="col-md-8 col-md-push-4 col-lg-9 col-lg-push-3">
<!--*******************************************Links**********************************************************-->
<div class="panel panel-warning">
<div class="panel-heading">Links</div>
<ul class="list-group">
<!--******************Start of displaying links*****************-->
#if(count($links_ind))
#foreach($links_ind as $link)
<li class="list-group-item">
<div class="row">
<div class="col-md-1 col-xs-1">
<a
href='/links/delete/{{ $link->link_id }}'
class='btn btn-danger btn-sm no-print'
onclick="return confirm ('Are you sure you want to delete this link?')">
<i class="fa fa-times"></i>
</a>
</div>
<div class="col-md-11 col-xs-11">
<div class="col-md-4 col-sm-5"><strong>Name</strong></div>
<div class="col-md-8 col-sm-7">
<a href='/individuals/{{ $link->ind_id }}'>{{ $link->FirstName.' '.$link->LastName }}</a>
</div>
#if ($link->Business_Phone)
<div class="col-md-4 col-sm-5"><strong>Business Phone</strong></div>
<div class="col-md-8 col-sm-7">{{ $link->Business_Phone }}</div>
#endif
#if ($link->Cell_Phone)
<div class="col-md-4 col-sm-5"><strong>Cell Phone</strong></div>
<div class="col-md-8 col-sm-7">{{ $link->Cell_Phone }}</div>
#endif
#if ($link->Spouse_Cell_Phone)
<div class="col-md-4 col-sm-5"><strong>Spouse Cell Phone</strong></div>
<div class="col-md-8 col-sm-7">{{ $link->Spouse_Cell_Phone }}</div>
#endif
#if ($link->HomePhone)
<div class="col-md-4 col-sm-5"><strong>Home Phone</strong></div>
<div class="col-md-8 col-sm-7">{{ $link->HomePhone }}</div>
#endif
</div>
</div>
</li>
#endforeach
#endif
#if(count($links_bus))
#foreach($links_bus as $link)
<li class="list-group-item">
<div class="row">
<div class="col-md-1 col-xs-1">
<a href='/links/delete/{{ $link->link_id }}'
class='btn btn-danger btn-sm no-print'
onclick="return confirm ('Are you sure you want to delete this link?')">
<i class="fa fa-times"></i>
</a>
</div>
<div class="col-md-11 col-xs-11">
<div class="col-md-4 col-sm-5"><strong>Name</strong></div>
<div class="col-md-7 col-sm-7">
<a href='/businesses/{{ $link->bus_bus_id }}'>{{ $link->company_name }}</a>
</div>
#if ($link->business_phone)
<div class="col-md-4 col-sm-5"><strong>Business Phone</strong></div>
<div class="col-md-7 col-sm-7">{{ $link->business_phone }}</div>
#endif
#if ($link->cell_phone)
<div class="col-md-4 col-sm-5"><strong>Cell Phone</strong></div>
<div class="col-md-7 col-sm-7">{{ $link->cell_phone }}</div>
#endif
#if ($link->fax)
<div class="col-md-4 col-sm-5"><strong>Fax</strong></div>
<div class="col-md-7 col-sm-7">{{ $link->fax }}</div>
#endif
#if ($link->email)
<div class="col-md-4 col-sm-5"><strong>Email</strong></div>
<div class="col-md-7 col-sm-7">{{ $link->email }}</div>
#endif
</div>
</div>
</li>
#endforeach
#endif
</ul>
</div>
<!--*******************************************************End of displaying links*************************************************-->
<!--*****************************************start of displaying notes************************************************-->
<div class="panel panel-success">
<div class="panel-heading">Notes</div>
<ul class="list-group">
#if(count($notes))
<!--***********************************Modal for each note*******************************************-->
#foreach($notes as $note)
<div class='modal fade'
id='myModal{{ $note->id }}'
name='myModal{{ $note->id }}'
tabindex='-1'
role='dialog'
aria-labelledby='myModalLabel'>
<div class='modal-dialog modal-lg' role='document'>
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button>
<h3 class='modal-title' id='myModalLabel'>Edit Note</h3>
</div>
<form method='post' action='/notes/save' role='form' name='new_note'>
{!! csrf_field() !!}
<div class='modal-body'>
<div class='form-group'>
<label for='note'>Edit the note and save your changes.</label>
<textarea class='form-control' rows='15' name='note' id='note' required>{{ $note->note }}</textarea>
<input type='hidden' name='ind_id' id='ind_id' value="{{ $id }}">
<input type='hidden' name='note_id' id='note_id' value="{{ $note->id }}">
<input type='hidden' name='timestamp' id='timestamp'>
</div>
</div>
<div class='modal-footer'>
<input type='submit' class='btn btn-primary' value='Save Changes' onclick='this.form.timestamp.value=Date.now()'>
<button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
</div>
</form>
</div>
</div>
</div>
<!--*****************************************End Modal for each note****************************************-->
<li class="list-group-item">
<div class="row">
<div class="col-lg-2 col-md-3 col-sm-2 col-xs-4">
<button type='button'
class='btn btn-warning no-print'
data-toggle='modal'
data-target='#myModal{{ $note->id }}'
>
<i class="fa fa-pencil-square-o"></i>
</button>
<a href='/notes/delete/{{ $note->id }}'
class='btn btn-danger no-print'
onclick="return confirm('Are you sure you want to delete this note?')"
><i class="fa fa-times"></i></a>
</div>
<div class="col-lg-2 col-md-3 col-sm-6 col-xs-8">{{ $note->user->name . ' ' . $note->user->last_name }}<br>{{ $note->timestamp->format('n/j/Y') }}</div>
<div class="col-lg-8 col-md-6 col-sm-12"><pre class="pre-note">{{ $note->note }}</pre></div>
</div>
</li>
#endforeach
#endif
</ul>
</div>
<!--******************************************end of displaying notes***************************************************-->
<!--*****************************************start of displaying invoices***********************************************
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title">Invoices</h3>
</div>
<div class="panel-body">
<ol>
#foreach($invoices as $invoice)
<li><a href='/invoice/pdf/{{ $invoice->id }}'>{{ date('m-d-Y', strtotime($invoice->date)) }}</a> {{ '$' . $invoice->amount }}</li>
#endforeach
</ol>
</div>
</div>
<!****************************************end of displaying invoices**************************************************-->
</div>
<script>
//This encodes the PHP array as JSON so that the autocomplete.js script can use it
var dataTwo = {!! $dataTwo !!};
</script>
</div>
</div>
Thank you
Jason
I didn't go through your whole code, but here is what I think is the problem. if for example you have a situation where you need to show
different number of columns on different screen sizes with bootstrap, please be specific with all column sizes. Don't let bootstrap guess.
here is what I mean:
for example you have this code:
<div class="col-lg-2 col-md-3 col-sm-2 col-xs-4">
<button type='button'
class='btn btn-warning no-print'
data-toggle='modal'
data-target='#myModal{{ $note->id }}'
>
<i class="fa fa-pencil-square-o"></i>
</button>
<a href='/notes/delete/{{ $note->id }}'
class='btn btn-danger no-print'
onclick="return confirm('Are you sure you want to delete this note?')"
><i class="fa fa-times"></i></a>
</div>
<div class="col-lg-2 col-md-3 col-sm-6 col-xs-8">{{ $note->user->name . ' ' . $note->user->last_name }}<br>{{ $note->timestamp->format('n/j/Y') }}</div>
<div class="col-lg-8 col-md-6 col-sm-12"><pre class="pre-note">{{ $note->note }}</pre></div>
You can see that you have specified the following for extra small screens: "col-xs-4", and "col-xs-8" for the first and second div's respectevely. What
about the third div? You have implied that it is "col-xs-12". I am afraid you will have to explicitely say that it is "col-xs-12".
so if you were to change your code to :
<div class="col-lg-2 col-md-3 col-sm-2 col-xs-4">
<button type='button'
class='btn btn-warning no-print'
data-toggle='modal'
data-target='#myModal{{ $note->id }}'
>
<i class="fa fa-pencil-square-o"></i>
</button>
<a href='/notes/delete/{{ $note->id }}'
class='btn btn-danger no-print'
onclick="return confirm('Are you sure you want to delete this note?')"
><i class="fa fa-times"></i></a>
</div>
<div class="col-lg-2 col-md-3 col-sm-6 col-xs-8">{{ $note->user->name . ' ' . $note->user->last_name }}<br>{{ $note->timestamp->format('n/j/Y') }}</div>
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12"><pre class="pre-note">{{ $note->note }}</pre></div>
It is going to work without any problem. Notice the explicit "col-xs-12" for the last div. The problem is on xtra small screens the first and second div's are floated left because they have "col-xs-..." whilst the third div is not floated and ends up causing chaos!
Have fun!!
I deployed a Symfony2 app, but all the forms have empty csrf tokens. This html comes from firebug. As you can see, the tag is properly rendered, but no value is assigned.
<input type="hidden" value="" name="category[_token]" id="category__token">
In my controller:
$form = $this->createForm(new CategoryForm(), new Category());
$form->handleRequest($request);
if ($form->isValid()) {
(...)
}
In the template, the form is inside of a bootstrap 3 modal.
{{ form_start(form) }}
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Voeg een tariefplan toe</h4>
</div>
<div class="modal-body">
<div class="form-group">
{{ form_label(form.name) }}
{{ form_widget(form.name) }}
</div>
<div class="form-group">
{{ form_label(form.parent) }}
{{ form_widget(form.parent, {'attr':{ 'class': 'form-control' }}) }}
</div>
<div class="form-group">
{{ form_label(form.sizes) }}
{{ form_widget(form.sizes, {'attr':{ 'class': 'form-control' }}) }}
</div>
<div class="form-group">
{{ form_label(form.description) }}
{{ form_widget(form.description, {'attr':{ 'class': 'form-control' }}) }}
</div>
{{ form_widget(form._token) }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Annuleren</button>
{{ form_widget(form.save, {'attr':{ 'class': 'btn btn-primary' }}) }}
</div>
</div>
</div>
{{ form_end(form) }}
I also created a gist for the CategoryForm class : http://goo.gl/6NWTkB.
Anyone who knows what I'm missing here?
You must provide the value:
<input type="hidden" value={{ csrf_token('category') }}"" name="category[_token]" id="category__token">
A couple of ideas:
{{ form_end(form) }} should output your token so there's no need to have: {{ form_widget(form._token) }}.
If you have a very large form php might truncate your request vars. Have a look at max_input_vars in your php.ini. Default is 1000 I believe.