Symfony 5 form fields appear when they should not - php

I display with twig a form for adding an event, with the possibility at the same time to create a new account if no user is connected. So I have one form integrated with another, my UserType form is integrated with my EventType form.
I made a condition that if the user is logged in, we will not display the registration form. Only that of event creation.
Here is my code :
{{ form_start(form) }}
{% if form.vars.valid == false %}
<div class="alert alert-danger">
Des erreurs ont été relevées. Merci de vérifier le formulaire.
</div>
{% endif %}
{% if app.user == false %}
<div id="general_info">
<h4> <i class="ion-ios-information"></i> À propos de vous</h4>
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.user.lastName, {'label': 'Votre nom *', 'attr': {'class': 'filter-input'}}) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.user.firstName, {'label': 'Votre prénom *', 'attr': {'class': 'filter-input'}}) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.user.password.first, {'label': 'Votre mot de passe *', 'attr': {'class': 'filter-input'}}) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.user.email, {'label': 'Votre adresse email *', 'attr': {'class': 'filter-input'}}) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.user.password.second, {'label': 'Confirmez votre mot de passe *', 'attr': {'class': 'filter-input'}}) }}
</div>
</div>
</div>
</div>
{% endif %}
<div id="event_and_category">
<h4><i class="ion-ios-list-outline"></i> Nom & Catégorie</h4>
<div class="row">
<div class="col-md-6">
{{ form_row(form.title) }}
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.category) }}
</div>
</div>
</div>
</div>
<div id="date_and_location">
<h4><i class="ion-ios-location"></i> Date & Localisation</h4>
<h5>Où se déroule votre événement ?</h5>
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.location) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.address) }}
{{ form_row(form.latitude) }}
{{ form_row(form.longitude) }}
</div>
</div>
<div class="col-md-6"></div>
<div class="col-md-6 no-padding mar-bot-20">
<div id="map"></div>
</div>
</div>
<h5>Quand se déroule votre événement ?</h5>
<div class="row">
<div class="col-md-6">
<div id="datepicker-from" class="input-group date" data-date-format="dd/mm/yyyy">
{{ form_row(form.startDate) }}
<span class="input-group-addon"><i class="icofont-ui-calendar"></i></span>
</div>
</div>
<div class="col-md-6">
<div id="datepicker-to" class="input-group date" data-date-format="dd/mm/yyyy">
{{ form_row(form.endDate) }}
<span class="input-group-addon"><i class="icofont-ui-calendar"></i></span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.startAt) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.endAt) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.dateDescription) }}
</div>
</div>
</div>
</div>
<div id="event_info">
<h4><i class="ion-ios-calendar-outline"></i> Votre événement</h4>
<h5>Informations de contact</h5>
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.contactName) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.contactEmail) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.contactPhone) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.organisatorEmail) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.organisatorPhone) }}
</div>
</div>
</div>
<h5>Décrivez votre événement</h5>
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.description) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.tags) }}
</div>
</div>
</div>
<h5>Choisissez une image pour votre événement</h5>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<div class="add-listing__input-file-box">
{{ form_row(form.coverFile) }}
<div class="add-listing__input-file-wrap">
<i class="ion-ios-cloud-upload"></i>
<p>Ajoutez une photo ou une image</p>
</div>
</div>
</div>
</div>
</div>
<h5>Bulletin d'inscription</h5>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<form class="photo-upload">
<div class="form-group">
<div class="add-listing__input-file-box">
{{ form_row(form.registrationForm) }}
<div class="add-listing__input-file-wrap">
<i class="ion-ios-cloud-upload"></i>
<p>Ajoutez un fichier</p>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<h5>Réseaux sociaux</h5>
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.website) }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form_row(form.facebookPage) }}
</div>
</div>
</div>
<h5>Annonce PREMIUM</h5>
<div class="row">
<div class="col-md-12 annonce-premium">
{{ form_row(form.featured) }}
</div>
</div>
{{ form_row(form._token) }}
{{ form_row(form.save) }}
</div>
{{ form_end(form) }}
So far everything is fine, if I logged in the "about you" part does not appear. My problem is that it appears lower !!
So after my submit button. How to solve this problem ?

In your form_end(form) line, add a flag to tell twig to not render unused forms:
{{ form_end(form, { 'render_rest': false }) }}

Related

Styles is not loading in my laravel program

I have a view which I'm returning in my AdminController which goes in this syntax.
public function create_booking(){
$set_admin = SettingAdmin::orderBy('id')->first();
return view('layouts\quickbookingmodal')->with('set_admin', $set_admin);
}
In HTML this is what im returning, this basically is a pop menu, where the admin user can fill a booking.
<div class="modal fade" id="myModal">
<div class=row>
<div class="col-sm-10 offset-sm-1">
<div class="modal-dialog modal-lg">
<form action="" method="POST">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Quick Booking</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
{{ csrf_field() }}
#isset($error_msg)
#foreach ($error_msg as $error)
<li class="text-danger">{{ $error }}</li>
#endforeach
#endisset
<div class="form-group row">
<label for="placeid" class="col-md-4 col-form-label text-md-right">{{ __('Place ID') }}: </label>
<div class="col-md-6">
<input type="text" class="form-control" name="place_id" required>
</div>
</div>
<div class="form-group row">
<label for="placeid" class="col-md-4 col-form-label text-md-right">{{ __('Arrival day') }}: </label>
<div class="col-md-6">
<div class="container11">
<div class="t-datepicker">
<span id="tdatepik" class="t-check-in"></span>
<input id="searchdate_numberofdays" type="number" name="no_of_day" placeholder="{{ __('Number of days') }}: 1">
#isset($maparray['err_msg'])
<span id="errormsg_txt" style="color:red;"> {{ __('You can book maximum') }} {{ $maparray["set_admin"]->max_no_days }} {{ __('days') }}.</span><br>
#endisset
<span id="errormsg_txt" style="color:red;display:none;"> {{ __('Arrival day is not selected') }}. </span><br>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label for="fullname" class="col-md-4 col-form-label text-md-right">{{ __('Full Name') }}: </label>
<div class="col-md-6">
<input type="text" class="form-control" name="user_fullname" required>
</div>
</div>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('Email address') }}: </label>
<div class="col-md-6">
<input type="email" class="form-control" name="user_email" required>
</div>
</div>
<div class="form-group row">
<label for="phone" class="col-md-4 col-form-label text-md-right">{{ __('Phone') }}: </label>
<div class="col-md-6">
<input type="tel" class="form-control" name="user_phone" required>
</div>
</div>
<div class="form-group row">
<label for="geust" class="col-md-4 col-form-label text-md-right">{{ __('Number of adults') }}[1-4]: </label>
<div class="col-md-6">
<select class="form-control booking_inp_textbox_style" id="numberofguest" name="numberofguest" onchange="addFieldsadmin(this.value);">
<option value="0" active>1</option>
<option value="1">2</option>
<option value="2">3</option>
<option value="3">4</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="babies" class="col-md-4 col-form-label text-md-right">{{ __('Number of babies') }}[1-3]: </label>
<div class="col-md-6">
<select class="form-control booking_inp_textbox_style" id="numberofbabies" name="numberofbabies" onchange="addFieldsadmin2(this.value);">
<option value="0" active>0</option>
<option id="hidden_op_style1" value="1">1</option>
<option id="hidden_op_style2" value="2">2</option>
<option id="hidden_op_style3" value="3">3</option>
</select>
</div>
</div>
<div class="containerinput">
{{-- dynamic input surname using javascript --}}
</div>
<div class="containerinput2">
{{-- dynamic input surname using javascript --}}
</div>
<div class="form-group row">
<label for="promo" class="col-md-4 col-form-label text-md-right">{{ __('Promo Code') }}: </label>
<div class="col-md-6">
<input type="text" class="form-control" name="user_promo">
</div>
</div>
<div class="form-group row">
<label for="book" class="col-md-4 col-form-label text-md-right">{{ __('Booked By') }}: </label>
<div class="col-md-6">
<label>{{ Auth::user()->name }}</label>
</div>
</div>
#if (Auth::user()->role == 'admin')
<div class="form-group row">
<label for="Amount" class="col-md-4 col-form-label text-md-right">{{ __('Payment Type') }}: </label>
<div class="col-md-6">
<input type="radio" name="user_payment_type" value="Entrance">
<label for="Entrance" class="booking_payment_type_style">{{ __('Entrance (Cash)') }}</label>
<input type="radio" name="user_payment_type" value="Admin" checked>
<label for="Entrance" class="booking_payment_type_style">{{ __('Admin (Free)') }}</label><br>
</div>
</div>
#else
<div class="form-group row">
<label for="promo" class="col-md-4 col-form-label text-md-right">{{ __('Payment Type') }}: </label>
<div class="col-md-6">
<input type="radio" name="user_payment_type" value="Entrance" checked>
<label for="Entrance" class="booking_payment_type_style">{{ __('Entrance (Cash)') }}</label>
</div>
</div>
#endif
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success">{{ __('Save') }}</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
var today = new Date();
tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 60);
var date = tomorrow.getFullYear()+'-'+(tomorrow.getMonth()+1)+'-'+tomorrow.getDate();
$(document).ready(function(){
// Call global the function
$('.t-datepicker').tDatePicker({
// options here
titleDateRange :'{{ __('day') }}',
titleDateRanges:'{{ __('days') }}',
titleToday :'{{ __('Today') }}',
limitDateRanges :'{{ $set_admin->max_no_days+1 }}',
titleCheckIn :'{{ __('Check In') }}',
titleCheckOut :'{{ __('Check Out') }}',
numCalendar : 1,
endDate: date,
nextDayHighlighted :false,
toDayHighlighted :true,
toDayShowTitle :true,
autoClose: true,
dateRangesHover: false,
});
});
// $('.t-datepicker').tDatePicker('setEndDate','2020-07-28');
</script>
<script type="text/javascript">
#isset($error_msg)
#if (count($error_msg) > 0)
$('#myModal').modal('show');
#endif
#endisset
</script>
But anytime i load the page, it does not load it as a popup just static HTML. However i have the same popup in this page called dashboard, which when clicked shows the popup perfectly with all the styles. I'm not sure why this is happening.
#extends('layouts.adminmaster')
#section('section')
<div class="container paddingTop20">
<h1>Negombo Admin Panel</h1>
<hr>
<div class="row">
<div class="col-sm-4">
<div class="card">
<div class="card-header bg-primary">
<span class="dashboardcardstyle">{{ __('Quick Booking') }}</span>
</div>
<div class="card-body">
<center><button type="button" class="btn btn-success dashboardcardbodystyle2" data-toggle="modal" data-target="#myModal">{{ __('Book Now') }}</button></center>
#include('layouts.quickbookingmodal')
</div>
</div>
</div>
<div class="col-sm-4">
<div class="card">
<div class="card-header bg-primary">
<span class="dashboardcardstyle">Total Places</span>
</div>
<div class="card-body">
<center><span class="dashboardcardbodystyle">{{ $numberofplace }}</span></center>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="card">
<div class="card-header bg-primary">
<span class="dashboardcardstyle">Total Bookings</span>
</div>
<div class="card-body">
<center><span class="dashboardcardbodystyle">{{ $numberofbookings }}</span></center>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
#include('layouts.recentactivaty')
</div>
<div class="col-sm-2">
</div>
</div>
{{-- second row of dashboard --}}
<div class="row paddingTop20">
<div class="col-sm-4">
#if (Auth::user()->role== "admin")
<div class="card">
<div class="card-header bg-primary">
<span class="dashboardcardstyle">Total Earnings</span>
</div>
<div class="card-body">
<table style="width:100%" align="center" class="table-hover">
<tr>
<td><strong>From Entrance: </strong></td>
<td>{{ $earningEntrance }} <i class="fa fa-eur" aria-hidden="true"></i></td>
</tr>
<tr>
<td><strong>From {{ __('Agreements') }}: </strong></td>
<td>{{ $earningAgr }} <i class="fa fa-eur" aria-hidden="true"></i></td>
</tr>
<tr>
<td><strong>From Paypal: </strong></td>
<td>{{ $earningPaypal }} <i class="fa fa-eur" aria-hidden="true"></i></td>
</tr>
<tr>
<td><strong>From Stripe: </strong></td>
<td> {{ $earningStripe }} <i class="fa fa-eur" aria-hidden="true"></i></td>
</tr>
<tr>
<td><strong>From Credit Card: </strong></td>
<td>{{ $earningcard }} <i class="fa fa-eur" aria-hidden="true"></i></td>
</tr>
</table>
{{-- <center><span class="dashboardcardbodystyle">{{ $numberofbookings }}</span></center> --}}
</div>
</div>
#else
<div class="card">
<div class="card-header bg-primary">
<span class="dashboardcardstyle">Server Time</span>
</div>
<div class="card-body">
<center><span>{{ date("d M, Y") }}</span></center>
<center><span class="dashboardcardbodystyle">{{ date("h:i:s A") }}</span></center>
</div>
</div>
#endif
</div>
<div class="col-sm-4">
<div class="card">
<div class="card-header bg-primary">
<span class="dashboardcardstyle">{{ __('Total') }} {{ __('Agreements') }}</span>
</div>
<div class="card-body">
<center><span class="dashboardcardbodystyle">{{ $numberofAggr }}</span></center>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="card">
<div class="card-header bg-primary">
<span class="dashboardcardstyle">Total Entrance</span>
</div>
<div class="card-body">
<center><span class="dashboardcardbodystyle">{{ $numberofEntrance }}</span></center>
</div>
</div>
</div>
</div>
{{-- second row of dashboard --}}
</div>
#endsection
This is how the popup is supposed to look like.
But this is how it looks
This is what i get when i add the #extends('layouts.adminmaster') and #section('section')

Laravel 5: Updatable List|Table

I'm trying to create an "updatable" order list|table where the user can change one dropdown value of the list to "take in charge" all orders listed.
(PS: user will also have the possibility to filter the list in order to take in charge only specific orders | order-row checkboxes will be removed since not necessary).
I have created my controller (using not Eloquent but query builder to query the data).
I'm passing my data to my view.
I can view the expected records in the list|table.
User can choose his name into the first order row dropdown called "Prise en charge", then all other order rows dropdowns values are changed accordingly :
https://www.screencast.com/t/Ei1wdJtb
(link works with Mozilla and Chrome but not Opera)
Now I would like to update with submit all in the table listed orders.
I know how to create CRUDs, but I never created this kind of hybrids, so it is a little bit unclear (or completely honestly said) how to do it.
I would appreciate some expertise about what is missing to submit and update accordingly the database table columns.
CONTROLLER
<?php namespace App\Http\Controllers;
use Session;
use Request;
use DB;
use CRUDBooster;
Use SoftDelete;
class AdminLaboOrdersManagementController extends Controller {
public function updateOrder(Request $request) {
# QUERIES
# I haven't printed the queries since it is not relevant I guess and
# because it takes a lot of space. If needed I will of course provide ...
# SEND TO VIEW
return view('labo_orders_mgt_view_index',
compact('staffs','orders','statusorders'));
}
}
BLADE
Structure
row-id is the row id of the order into the table
<div class="order" row-id="1029">rows and data</div>
<div class="order" row-id="1039">rows and data</div>
<div class="order" row-id="1049">rows and data</div>
<div class="order" row-id="1059">rows and data</div>
<div class="order" row-id="1060">rows and data</div>
<div class="order" row-id="1062">rows and data</div>
Code
#extends('crudbooster::admin_template')
#section('content')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="{{ asset('assets/js/laboratory/takeCareOf.js')}}"></script>
<table class='table table-striped table-bordered'>
<tbody>
{{--dd($staffs)--}}
{{--dd($orders)--}}
<!-- FOREACH LOOP TO DISPLAY THE ORDERS -->
<form method="POST" action="" id="takecareof">
<div class='row button'>
<button type="submit" class="btn btn-primary btn-sm" id="btnFront" style="cursor: pointer;font-size:24px; height:47px;width:100%;"> Je confirme la prise en charge </button>
</div>
#foreach($orders as $order)
<div class="order" row-id="{{$order->rowID}}">
<div class="col-md-1 sub_chkbox">
<input type="checkbox" class="sub_chk" data-id="{{$order->rowID}}">
</div>
<div class="row">
<div class="col-md-2 takecareof">
<h5>Prise en charge par</h5>
<p>
<select name="dropdownlabostaffs" class="dropdownlabostaffs form-control">
#if (isset($staffs))
<option value="">Artisans</option>
#foreach ($staffs as $staff)
<option value="{{ $staff->staffID }}"{{ $staff->staffID == $order->ownerID ? 'selected' : '' }}>{{ $staff->staffName }}</option>
#endforeach
#endif
</select>
</p>
</div>
</div>
#if($order->FirstnameUser === NULL || $order->LastnameUser === NULL)
<div class="row">
<div class="col-md-2 ordernr">
<h5>Commande no</h5>
<p>
{{ $order->orderID }}
</p>
</div>
<div class="col-md-3 orderby">
<h5>Commandé par</h5>
<p>
#if(isset($order->FirstnameUser)) {{ $order->FirstnameUser }} #endif #if(isset($order->LastnameUser)) {{ $order->LastnameUser }} #endif
</p>
</div>
<div class="col-md-3 forcustomer">
<h5>Pour Client</h5>
<p>
#if(isset($order->FirstnameCustomer)) {{ $order->FirstnameCustomer }} #endif #if(isset($order->LastnameCustomer)) {{ $order->LastnameCustomer }} #endif
</p>
</div>
<div class="col-md-3 laboratory">
<h5>Laboratoire</h5>
<p>
{{ $order->Laboratory }}
</p>
</div>
</div>
#else
<div class="row">
<div class="col-md-2 ordernr">
<h5>Commande no</h5>
<p>
{{ $order->orderID }}
</p>
</div>
<div class="col-md-3 orderby">
<h5>Commandé par</h5>
<p>
#if(isset($order->FirstnameUser)) {{ $order->FirstnameUser }} #endif #if(isset($order->LastnameUser)) {{ $order->LastnameUser }} #endif
</p>
</div>
<div class="col-md-3 forcustomer">
<h5>Pour Client</h5>
<p>
#if(isset($order->FirstnameCustomer)) {{ $order->FirstnameCustomer }} #endif #if(isset($order->LastnameCustomer)) {{ $order->LastnameCustomer }} #endif
</p>
</div>
<div class="col-md-3 laboratory">
<h5>Laboratoire</h5>
<p>
{{ $order->Laboratory }}
</p>
</div>
</div>
#endif
<div class="row">
<div class="col-md-6 status">
<h5>Statut</h5>
<p>
<select name="statusorder" class="statusorder form-control">
#if (isset($statusorders))
<option value="">Status</option>
#foreach ($statusorders as $statusorder)
<option value="{{ $statusorder->statusorderID }}"{{ $statusorder->statusorderID == $order->StatusID ? 'selected' : '' }}>{{ $statusorder->statusorderName }}</option>
#endforeach
#endif
</select>
</p>
</div>
<div class="col-md-6 pickup">
<h5>Date | heure de retrait</h5>
<p>
{{ date('d-m-Y', strtotime($order->{'DeliveryDate'})) }} | 13:15
</p>
<p>
</p>
</div>
</div>
<div class="row">
<div class="col-md-2 category">
<h5>Catégorie</h5>
<p>
#if(isset($order->Type)) {{ $order->Type }} #endif
</p>
</div>
<div class="col-md-2 product">
<h5>Produit</h5>
<p>
#if(isset($order->Name)) {{ $order->Name }} #endif
</p>
</div>
#if($order->Type === 'Gâteaux' || $order->Type === 'Tarte' || $order->Type === 'Tarte-fine')
<div class="col-md-2 servings">
<h5># Personnes</h5>
<p>
#if(isset($order->Servings)) {{ $order->Servings }} #endif
</p>
</div>
#endif
#if($order->Type === 'Gâteaux' || $order->Type === 'Tarte' || $order->Type === 'Tarte-fine')
<div class="col-md-2 chocodeco">
<h5>Déco Choco</h5>
#if(strpos($order->DecoChocoFruits, 'souhaitée') !== false)
<p>Oui</p>
#else
<p>Non</p>
#endif
</div>
<div class="col-md-4 flowerdeco">
<h5>Déco Fleurs</h5>
#if(strpos($order->DecoSmallFlowers, 'souhaitée') !== false)
<p>Oui</p>
#else
<p>Non</p>
#endif
</div>
#endif
#if($order->Type === 'Pain-surprise')
<div class="col-md-2 weight">
<h5>Poids</h5>
<p>
#if(isset($order->Weight)) {{ $order->Weight }} #endif
</p>
</div>
<div class="col-md-4 colorribbon">
<h5>
Couleur Ruban
</h5>
<p>
#if(isset($order->RibbonColor)) {{ $order->RibbonColor }} #endif
</p>
</div>
#endif
#if($order->Type === 'Pain')
<div class="col-md-2 breadquantity">
<h5>
Quantité
</h5>
<p>
#if(isset($order->BreadQuantity)) {{ $order->BreadQuantity }} #endif
</p>
</div>
<div class="col-md-6 slicecut">
<h5>
Coupe
</h5>
#if(strpos($order->Cut, 'souhaitée') !== false)
<p>Oui</p>
#else
<p>Non</p>
#endif
</div>
#endif
#if($order->Type === 'Salé')
<div class="col-md-2 savouryquantity">
<h5>
Quantité
</h5>
<p>
#if(isset($order->SavouryQuantity)) {{ $order->SavouryQuantity }} #endif
</p>
</div>
<div class="col-md-6 savouryassortment">
<h5>
Assortiment
</h5>
<p>
#if(isset($order->CanapésAssortment)) {{ $order->CanapésAssortment }} #endif
#if(isset($order->MiniPuffsAssortment)) {{ $order->MiniPuffsAssortment }} #endif
#if(isset($order->VolsAuVentAssortment)) {{ $order->VolsAuVentAssortment }} #endif
#if(isset($order->AppetisersAssortment)) {{ $order->AppetisersAssortment }} #endif
</p>
</div>
#endif
#if($order->Type === 'Sucré')
<div class="col-md-2 sweetquantity">
<h5>
Quantité
</h5>
<p>
#if(isset($order->SweetQuantity)) {{ $order->SweetQuantity }} #endif
</p>
</div>
<div class="col-md-6 sweetassortment">
<h5>
Coupe
</h5>
<p>
#if(isset($order->SweetAssortment)) {{ $order->SweetAssortment }} #endif
</p>
</div>
#endif
</div>
<div class="row">
#if($order->Type === 'Pain-surprise')
<div class="col-md-3 variante1">
<h5>
Assortiment 1
</h5>
<p>
#if(isset($order->Assortment1)) {{ $order->Assortment1 }} #endif
</p>
</div>
<div class="col-md-3 variante2">
<h5>
Assortiment 2
</h5>
<p>
#if(isset($order->Assortment2)) {{ $order->Assortment2 }} #endif
</p>
</div>
<div class="col-md-3 variante3">
<h5>
Assortiment 3
</h5>
<p>
#if(isset($order->Assortment3)) {{ $order->Assortment3 }} #endif
</p>
</div>
<div class="col-md-3 variante4">
<h5>
Assortiment 4
</h5>
<p>
#if(isset($order->Assortment4)) {{ $order->Assortment4 }} #endif
</p>
</div>
#endif
</div>
</div>
#endforeach
</form>
</tbody>
</table>
<!-- ADD A PAGINATION -->
<p></p>
#endsection

How to update only few columns of an Entity by a form

I have a User Entity and I collect all the data in a form called Register. But once after registering, I want to edit some of the fields of a user by a form. But some fields are avoided being updated (email) and Password field is optional. I tried rendering the same register form but $form->handleRequest($request) throws an error saying:
Expected argument of type "string", "NULL" given at property path
"password".
I want to know if there is a way to do this?
I tried $form->submit($request->request->get($form->getName()),false);
instead of $form->handleRequest($request); but it didn't work.
// This is my controller.
/**
* #Route("/update/{id}", name="update")
* #param $id
* #param Request $request
* #param UserPasswordEncoderInterface $passwordEncoder
* #param UserRepository $userRepository
* #return \Symfony\Component\HttpFoundation\RedirectResponse|Response
*/
public function updateUser($id,Request $request, UserPasswordEncoderInterface $passwordEncoder, UserRepository $userRepository){
$user = $userRepository->find($id);
$form = $this->createFormBuilder($user)
->add('email',EmailType::class,[
'label'=>'Email',
'required' => false,
'attr'=>['placeholder'=>"Email"]
])
->add('password',RepeatedType::class,[
'type' => PasswordType::class,
'invalid_message' => 'The password fields must match.',
'required' => false,
'options' => ['attr' => ['class' => 'password-field']],
'first_options' => ['label' => 'Password','attr'=>['placeholder'=>"Password"]],
'second_options' => ['label' => 'Confirm Password','attr'=>['placeholder'=>"Confirm Password"]],
])
->add('firstName',TextType::class,['label'=>'First Name', 'attr'=>['placeholder'=>"First Name"]])
->add('lastName',TextType::class,['label'=>'Last Name','attr'=>['placeholder'=>"Last Name"]])
->add('address',TextareaType::class,['required' => false,'label'=>'Address','attr'=>['placeholder'=>"Address"]])
->add('idNumber',TextType::class,['label'=>'NIC Number','attr'=>['placeholder'=>"NIC Number"]])
->add('phoneNumber',TelType::class,['label'=>'Phone Number','attr'=>['placeholder'=>"Phone Number"]])
->add('image',FileType::class,['label'=>'Photo','required'=>false,'attr'=>['hidden'=>"hidden", 'accept'=>"image/jpeg, image/png"]])
->add('save',SubmitType::class,[
'label'=>'Register',
'attr' => [
'class'=>"btn btn-outline-success float-right"
]
])
->getForm();
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid()){
if($user->getPassword() !=""){
$user->setPassword($passwordEncoder->encodePassword($user,$user->getPassword()));
}
$em = $this->getDoctrine()->getManager();
$em->flush();
return $this->redirectToRoute('home');
}
return $this->render('register/update.html.twig', [
'form'=>$form->createView(),
]);
}
// And this is my TWIG file.
{% extends 'base.html.twig' %}
{% block title %}Edit Info{% endblock %}
{% block refHome %}{{ path('main') }}{% endblock %}
{% block body %}
<div class="container" style=" margin-left: auto;margin-right: auto;margin-top: 1cm;" >
<div class="row">
{# <div class="col-lg-2"></div>#}
<div class="col-lg-10">
<div class="card" style="width: 50rem;text-align: center;">
<div class="card-body">
<h3 class="card-title float-left">Edit Info</h3>
<div style="margin-top: 2cm;">
<p class="card-text">
<form name="register" id="register_form" method="post" enctype="multipart/form-data">
<div id="register">
<div class="container">
<div class="row">
<div class="col-sm-5">
{{ form_errors(form.firstName) }}
{{ form_widget(form.firstName) }}
</div>
<div class="col-sm-2"></div>
<div class="col-sm-5">
{{ form_errors(form.lastName) }}
{{ form_widget(form.lastName) }}
</div>
</div>
<div style="margin-top: 0.5cm;"></div>
<div class="row">
<div class="col-sm-6">
{{ form_errors(form.email) }}
{{ form_widget(form.email) }}
</div>
<div class="col-sm-1"></div>
<div class="col-sm-5">
{{ form_errors(form.idNumber) }}
<input type="text" id="register_idNumber" placeholder="NIC Number" onkeypress="isInputNumber(event)" pattern="^[0-9]{9}[a-zA-Z]$" value="{{ form.idNumber.vars.value }}" name="register[idNumber]" required="required" class="form-control" " /> <div class="input-group-append">
</div>
</div>
</div>
<div style="margin-top: 0.5cm;"></div>
<div class="row">
<div class="col-sm-5">
<div style="margin-top: 0.5cm;"></div>
{{ form_errors(form.phoneNumber) }}
<input type="tel" id="register_phoneNumber" value="{{ form.phoneNumber.vars.value }}" name="register[phoneNumber]" onkeypress="isPhone(event)" required="required" placeholder="Phone Number" class="form-control" pattern="^[0-9]{10}$" />
</div>
<div class="col-sm-2"></div>
</div>
<div style="margin-top: 0.5cm;"></div>
<div class="row" >
<div class="col-sm-7">
{{ form_errors(form.address) }}
{{ form_widget(form.address) }}
</div>
<div class="col-sm-1" hidden="hidden">
{{ form_widget(form.image) }}
</div>
</div>
<div style="margin-top: 0.5cm;"></div>
<div class="form-group row">
<div class="col-sm-7">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="defaultUnchecked" style="float: left">
<label class="custom-control-label" for="defaultUnchecked">Change Password</label>
</div>
</div>
</div>
<div style="margin-top: 0.5cm;"></div>
<div id="register_password" >
<div class="form-group row">
{% for passwordField in form.password %}
<div class="col-sm-5">
{{ form_errors(passwordField) }}
{{ form_widget(passwordField) }}
</div>
<div class="col-sm-2"></div>
{% endfor %}
</div>
<div style="margin-top: 0.5cm;"></div>
</div>
</div>
{{ form_widget(form.save,{'label':"Update"}) }}
{{ form_widget(form._token) }}
{{ form_errors(form) }}
</form>
</p>
</div>
</div>
</div>
</div>
<div class="col-lg-1"></div>
</div>
</div>
{% endblock %}
{% block javascripts %}
<script>
const checkBoxPwd = document.getElementById('defaultUnchecked');
const pwdDiv = document.getElementById('register_password');
pwdDiv.style.visibility = "hidden";
checkBoxPwd.addEventListener("change",function () {
if (checkBoxPwd.checked == true){
pwdDiv.style.visibility = "visible";
}else{
pwdDiv.style.visibility = "hidden";
}
});
</script>
<script>
function isInputNumber(eve) {
var ch = String.fromCharCode(eve.which);
if (document.getElementById('register_idNumber').value.length < 9){
if (!(/[0-9]/.test(ch))){
eve.preventDefault();
}
}else {
if (!(/[a-zA-Z]/.test(ch))){
eve.preventDefault();
}
}
if (document.getElementById('register_idNumber').value.length > 9){
eve.preventDefault();
}
}
function isPhone(eve) {
var ch = String.fromCharCode(eve.which);
if (!(/[0-9]/.test(ch))){
eve.preventDefault();
}
if (document.getElementById('register_phoneNumber').value.length > 9){
eve.preventDefault();
}
}
</script>
{% endblock %}

Laravel form with multiple select didn't send all selected data when submit

I have Laravel form with many multiple select elements which has many data. for ex:
Hotel select (600 option)
Restaurants select (800 option)
SPA select (200 option)
Attractions select (150 option)
Outlets select (500 option)
If I select all options in all inputs, in the controller when checking the
request the (Outlets) item has only 200 option
how to fix this? how to got all data sent from this form?
is there any form data size in Laravel?
This my form code:
<div class="row">
<div class="panel panel-white">
<div class="panel-body">
<div class="col-md-12 col-sm-12">
<div class="form-group">
{{ Form::label('hotels', __('membership::main.hotels')) }}
{{ Form::select('hotels', $hotels, null, array('multiple'=>'multiple','name'=>'hotels[]', 'class' => 'multiselect form-control')) }}
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="panel panel-white">
<div class="panel-body">
<div class="col-md-12 col-sm-12">
<div class="form-group">
{{ Form::label('outlets', __('membership::main.outlets')) }}
{{ Form::select('outlets', $outlets, null, array('multiple'=>'multiple','name'=>'outlets[]', 'class' => 'multiselect form-control')) }}
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="panel panel-white">
<div class="panel-body">
<div class="col-md-12 col-sm-12">
<div class="form-group">
{{ Form::label('airports', 'Airport & Lounges') }}
{{ Form::select('airports', $airports, null, array('multiple'=>'multiple','name'=>'airports[]', 'class' => 'multiselect form-control')) }}
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="panel panel-white">
<div class="panel-body">
<div class="col-md-12 col-sm-12">
<div class="form-group">
{{ Form::label('beauty', 'Beauty & Fitness') }}
{{ Form::select('beauty', $beauty, null, array('multiple'=>'multiple','name'=>'beauty[]', 'class' => 'multiselect2 form-control')) }}
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="panel panel-white">
<div class="panel-body">
<div class="col-md-12 col-sm-12">
<div class="form-group">
{{ Form::label('attractions', 'Activities & Attractions') }}
{{ Form::select('attractions', $attractions, null, array('multiple'=>'multiple','name'=>'attractions[]', 'class' => 'multiselect2 form-control')) }}
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="panel panel-white">
<div class="panel-body">
<div class="col-md-12 col-sm-12">
<div class="form-group">
{{ Form::label('restaurants', 'Restaurant & Bars') }}
{{ Form::select('restaurants', $restaurants, null, array('multiple'=>'multiple','name'=>'restaurants[]', 'class' => 'multiselect3 form-control')) }}
</div>
</div>
</div>
</div>
</div>
And I am using this library to handle multiselect function
https://github.com/davidstutz/bootstrap-multiselect
in controller I just checking the data like this, and I not all my selection was submitted, its stop on specific limit but I don't know why?
public function store(Request $request)
{
dd($request);
}
Having so much options is not Ideal! However, I propose you look at your controller. Its possible that you paginate your result. Also it could be browser related. Until we see what you have done or what you seeing, we cannot give your an exact answer...only assumptions

Laravel multipule relationships count

I have these models:
ForumCategory
Forum
Topic
Reply
In the main forum page, I want to count and display the number of replies that associated to this forum.
All the models have relationships.
This is the view:
#foreach ($categories as $category)
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default striped">
<div class="panel-heading">
<div class="row">
<div class="col-md-11">{{ $category->name }}</div>
<div class="col-md-1 text-right"><a><span class="fa fa-arrow-down"></span></a></div>
</div>
</div>
#foreach ($category->forums as $forum)
<div class="panel-body">
<div class="row">
<div class="col-md-1 text-right"><span class="fa fa-envelope fa-4x"></span></div>
<div class="col-md-7">
<h4>
{{ $forum->name }}
<br>
<small>{{ $forum->description }}</small>
</h4>
</div>
<div class="col-md-1 post-num">
<h5>{{ $forum->topics->count() }}<br>
<small>Topics</small></h5>
<h5>{{ $forum->topics->replies->count() }}<br>
<small>Replies</small></h5>
</div>
<div class="col-md-3">
<img src="" class="img-circle last-comnt-img">
Last comment<br>
By Username<br>
<span class="text-muted">12:31</span>
</div>
</div>
</div>
#endforeach
</div>
</div>
</div>
</div>
#endforeach
This line won't work:
$forum->topics->replies->count()

Categories