I have a nested group Angular form. I want to take the group's controls values and match the name of the controls to my JSON object - forms

I have a small contact form that I have built using Angular. I want to validate the form and change the form data to JSON object.
Here's my Form:
<form [formGroup]="addContactForm" (ngSubmit)="onSubmit()" novalidate >
<div [hidden]="addcontactForm.submitted">
<div class="modal-body" style="overflow: auto">
<!-- create contact -->
<div style="padding: 0 0px 0px 25px;margin-top:30px;">
<div class="form-horizontal">
<span *ngIf="ACname.invalid && (ACname.dirty || ACname.touched)" class="has-error">
<span *ngIf="ACname.errors.required">
Last Name is required.
</span>
</span>
<!-- name -->
<div FormGroupName="ACname">
<div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': ACname.addContactFirstName.invalid && (ACname.addContactFirstName.dirty || ACname.addContactFirstName.touched) }">
<label class="col-sm-3" for="addContactFirstName">First Name</label>
<div class="col-sm-7">
<input id="addFirstName"
formControlName="addContactFirstName"
class="form-control"
placeholder="Enter First Name" />
</div>
</div>
<div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': ACname.addContactLastName.invalid && (ACname.addContactLastName.dirty || ACname.addContactLastName.touched) }">
<label class="col-sm-3" for="addContactLastName">Last Name</label>
<div class="col-sm-7">
<input id="addLastName"
class="form-control"
formControlName="addContactLastName"
placeholder="Enter Last Name" />
</div>
</div>
</div>
<div FormGroupName="ACcontactMethod">
<!-- office phone -->
<div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': ACcontactMethod.addcontactForm.submitted && !ACcontactMethod.addContactOfficePhone.valid }">
<label class="col-sm-3" for="addContactOfficePhone">Office Phone</label>
<div class="col-sm-7">
<input id="addofcPhone"
type="text"
class="form-control"
formControlName="addContactOfficePhone"
placeholder="Enter Office Number" />
<span *ngIf="addContactOfficePhone.invalid && (addContactOfficePhone.dirty || addContactOfficePhone.touched)" class="has-error">
<span *ngIf="addContactLastName.errors.required">
Name is required.
</span>
</span>
</div>
</div>
<!-- mobile phone -->
<div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': addcontactForm.submitted && !addContactMobilePhone.valid }">
<label class="col-sm-3" for="addContactMobilePhone">Mobile Phone</label>
<div class="col-sm-7">
<input id="addmobPhone"
type="text"
class="form-control"
formControlName="addContactMobilePhone"
placeholder="Enter Mobile Number" />
<span *ngIf="addContactMobilePhone.invalid && (addContactMobilePhone.dirty || addContactMobilePhone.touched)" class="has-error">
<span *ngIf="addContactMobilePhone.errors.required">
Name is required.
</span>
</span>
</div>
</div>
<!-- home phone -->
<div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': addcontactForm.submitted && !addContactHomePhone.valid }">
<label class="col-sm-3" for="addContactHomePhone">Home Phone</label>
<div class="col-sm-7">
<input id="addhomPhone"
type="text"
class="form-control"
formControlName="addContactHomePhone"
placeholder="Enter Home Number" />
<span *ngIf="addContactHomePhone.invalid && (addContactHomePhone.dirty || addContactHomePhone.touched)" class="has-error">
<span *ngIf="addContactHomePhone.errors.required">
Name is required.
</span>
</span>
</div>
</div>
<!-- email -->
<div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': addcontactForm.submitted && !addContactEmail.valid }">
<label class="col-sm-3" for="addContactEmail">Email</label>
<div class="col-sm-7">
<input id="addEmail"
type="email"
class="form-control"
formControlName="addContactEmail"
placeholder="Enter Email" />
<span *ngIf="addContactEmail.invalid && (addContactEmail.dirty || addContactEmail.touched)" class="has-error">
<span *ngIf="addContactEmail.errors.required">
Name is required.
</span>
</span>
</div>
</div>
<!-- chat id -->
<div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': addcontactForm.submitted && !addContactChatId.valid }">
<label class="col-sm-3" for="addContactChatId">Chat ID</label>
<div class="col-sm-7">
<input id="addChatID"
type="text"
class="form-control"
formControlName="addContactChatId"
placeholder="Enter Chat ID" />
<span *ngIf="addContactChatId.invalid && (addContactChatId.dirty || addContactChatId.touched)" class="has-error">
<span *ngIf="addContactChatId.errors.required">
Name is required.
</span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" (click)="addcontactForm.reset()" data-dismiss="modal">Close</button>
<button type="submit"
class="btn btn-primary"
[disabled]="!addcontactForm.valid"
(click)="addContact(model);">
Add Contact
</button>
</div>
</div>
<div class="submitted-message" *ngIf="addcontactForm.submitted">
<p>You've submitted your contact, {{ addcontactForm.value.addContactFirstName }} {{ addcontactForm.value.addContactLastName }}!</p>
<button type="button" class="btn btn-default pull-left" (click)="addcontactForm.reset()" data-dismiss="modal">Close</button>
<button (click)="addcontactForm.resetForm({})">Add new Contact </button>
</div>
</form>
Here's my ts:
import { Component} from '#angular/core';
import { AppComponent } from '../app.component';
import { FormBuilder, Validators, FormGroup, FormControl } from '#angular/forms';
#Component({
selector: 'addcontactmodal',
templateUrl: 'addcontact.component.html'
})
export class AddContactModalComponent {
id: any;
addContactForm: FormGroup;
constructor(private _appComponent: AppComponent, private fb: FormBuilder) {
this.id = localStorage.getItem('Id');
this.addContactForm = this.fb.group({
ACname: new FormGroup({
addContactFirstName: new FormControl('', Validators.minLength(40)),
addContactLastName: new FormControl('', Validators.minLength(40)),
}),
ACcontactMethod: new FormGroup({
addContactOfficePhone: new FormControl('', Validators.minLength(20)),
addContactMobilePhone: new FormControl('', Validators.minLength(20)),
addContactHomePhone: new FormControl('', Validators.minLength(20)),
addContactEmail: new FormControl('', Validators.minLength(127)),
addContactChatId: new FormControl('', Validators.minLength(127))
})
});
}
// private method(s)
private addContact() {
let data = {
ChatId: this.fb.group('addContactChatId').value,
Email: addContactEmail,
FirstName: addContactFirstName,
HomePhone: addContactHomePhone,
MobilePhone: addContactMobilePhone,
LastName: addContactLastName,
OfficePhone: this.model.addContactOfficePhone
}
this._appComponent.signalRService.setAgentContact(this.id, data);
}
}
I want to:
Validate the form
Have the data output to JSON
I do not get any of the validation the form promises. It doesn't submit.
Errors:
nhandled Promise rejection: Cannot read property 'invalid' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'invalid' of undefined
at Object.View_AddContactModalComponent_0.co [as updateDirectives]

You are not using complete property paths for your validation messages. Here's a simplified template of yours:
<form [formGroup]="addContactForm" (ngSubmit)="onSubmit()" novalidate >
<!-- formGroupName - mark all form controls belonging to this group inside tag -->
<div formGroupName="ACname">
<input formControlName="addContactFirstName" />
<!-- use complete property path or do like follows! -->
<span *ngIf="addContactForm.hasError('minlength', 'ACname.addContactFirstName')">
Minlength 40
</span>
</div>
</form>
StackBlitz

Related

Google Sheets HTML data input, can't get it to populate

Spreadsheet:
The html data entry:
I have been working on this for 8 hours, I cannot figure it out.
I have a website that I am uploading items to be sold. I have a Google sheet that I am keeping track of this information. We will have probably over 3,000 items to sell, so this html would be a lifesaver!
I however cannot get it to populate into my Google sheets. It runs, I don't get error messages, it just won't populate in my sheet.
This is my sheet, it is open
I am teaching myself how to do the website myself, I only have about 3 or 4 months under my belt. Any help would be WONDERFUL!
Code GS
function doGet(request) {
return HtmlService.createTemplateFromFile("Index").evaluate();
}
/* #Include JavaScript and CSS Files */
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename).getContent();
}
/* #Process Form */
function processForm(formObject) {
var url =
"https://docs.google.com/spreadsheets/d/1uF5YBKyfVxvrA4QrUuRqHrxe7C1qEySIxAL_r-PkBIQ/edit#gid=1180254005";
function processForm(formObject) {
var ss = SpreadsheetApp.getActive();
var ws = ss.getSheetByName("Data");
ws.appendRow([
formObject.location,
formObject.itemNumber,
formObject.name,
formObject.description,
formObject.price,
formObject.markedDown,
formObject.pricePaid,
formObject.category,
formObject.sold,
formObject.postedOnline,
]);
}
}
Index.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<?!= include('JavaScript'); ?>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-6">
<form id="myForm" onsubmit="handleFormSubmit(this)">
<p class="h4 mb-4 text-center font-weight-bold">Seattle Bound Data</p>
<!-- Row 1 -->
<div class="form-row">
<div class="form-group col-md-4 font-weight-bold">
<label for="first_name">Location</label>
<input type="text" class="form-control" id="location" name="location" placeholder="Location">
</div>
<div class="form-group col-md-4 font-weight-bold">
<label for="itemNumber">Item Number</label>
<input type="text" class="form-control" id="itemNumber" name="itemNumber" placeholder="Item Number">
</div>
<div class="form-group col-md-4 font-weight-bold">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Name">
</div>
</div>
<!-- Row 1 -->
<!-- Row 2 -->
<div class="form-row">
<div class="form-group col-lg-12 font-weight-bold">
<label for="description">Description</label>
<input type="text" class="form-control" id="description" name="description" placeholder="Description">
</div>
</div>
<!-- Row 2 -->
<!-- Row 3 -->
<div class="form-row">
<div class="form-group col-md-4 font-weight-bold">
<label for="price">Price</label>
<input type="number" class="form-control" id="price" name="price" placeholder="$00.00">
</div>
<div class="form-group col-md-4 font-weight-bold">
<label for="markedDown">Marked Down</label>
<input type="number" class="form-control" id="markedDown" name="markedDown" placeholder="$00.00">
</div>
<div class="form-group col-md-4 font-weight-bold">
<label for="pricePaid">Price Paid</label>
<input type="number" class="form-control" id="pricePaid" name="pricePaid" placeholder="$0.00">
</div>
</div>
<!-- Row 3 -->
<!-- Row 4 -->
<div class="form-row">
<div class="form-group col-sm-6 font-weight-bold">
<label for="categories">Categories</label>
<div class="form-check form-check-inline">
<select name="categories">
<option value="media">Media</option>
<option value="tools">Tools</option>
<option value="clothes">Clothes</option>
<option value="bears">Bears</option>
<option value="misc">Misc</option>
<option value="electronics">Electronics</option>
</select>
<div class="form-group col-sm-6 font-weight-bold">
<p>Sold</p>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="sold" id="true" value="true">
<label class="form-check-label" for="true">True</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="sold" id="false" value="false">
<label class="form-check-label" for="false">False</label>
</div>
</div>
<div class="form-group col-sm-6 font-weight-bold">
<p>Posted Online</p>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="postedOnline" id="true" value="true">
<label class="form-check-label" for="true">True</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="postedOnline" id="false" value="false">
<label class="form-check-label" for="false">False</label>
</div>
</div>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary btn-block">Submit</button>
</form>
<div id="output"></div>
</div>
</div>
</div>
</body>
</html>
JavaScript.html
<script>
// Prevent forms from submitting.
function preventFormSubmit() {
var forms = document.querySelectorAll('form');
for (var i = 0; i < forms.length; i++) {
forms[i].addEventListener('submit', function(event) {
event.preventDefault();
});
}
}
window.addEventListener('load', preventFormSubmit);
function handleFormSubmit(formObject) {
google.script.run.processForm(formObject);
document.getElementById("myForm").reset();
}
</script>
I was able to run the code but with few corrections.
In app script, inside the pocessForm() function you are again declaring a new function with the same name, which is unnecessary and your code does not run because of this. So you should remove the outer function and just keep inner one.
When you deploy your app, the activeSheet function does not work. Instead, use
SpreadsheetApp.openById("")
and give the id of the spreadsheet which you can find in the link of the spreadsheet. These will be the alphanumeric character string. For your sheet it's this - "1uF5YBKyfVxvrA4QrUuRqHrxe7C1qEySIxAL_r-PkBIQ".
function doGet(request) {
return HtmlService.createTemplateFromFile('Index').evaluate();
}
/* #Include JavaScript and CSS Files */
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename).getContent();
}
/* #Process Form */
function processForm(formObject) {
Logger.log(JSON.stringify(formObject));
// var ss = SpreadsheetApp.getActive(); // incorrect
const ss = SpreadsheetApp.openById("");
const ws = ss.getSheetByName('Data');
ws.appendRow([formObject.location,
formObject.itemNumber,
formObject.name,
formObject.description,
formObject.price,
formObject.markedDown,
formObject.pricePaid,
formObject.category,
formObject.sold,
formObject.postedOnline]);
}
And this works.
Suggestion - You may want to handle the form validation. Currently, if a user submits the form with any empty field, app script throws error. Easy way to handle this is by making each input field required in html.

Nuxt and Netlify Form File Upload Problem

in a Nuxt site I have a form with a field of type "file", and a Name, Email and Message fields.
Name, Email and Message are working flawlessy everytime, instead the "file" field ONLY WORKS when the first page visited is the page where the form is (or it's reloaded). If a user, let's say, land on the homepage and only then reach the form page, the message sent from the form will not contain the file that was attached.
What can cause this? I've already tried to reset the form on the mounted hook, or reset only the "file" field but with no luck.
This is the form component code "TheFormJob.vue":
<template>
<div>
<form name="job" netlify-honeypot="bot-field" method="post" action="/success" data-netlify="true">
<input type="hidden" name="form-name" value="job" >
<p class="hidden">
<label>Don’t fill this out: <input name="bot-field"></label>
</p>
<div class="form">
<div class="form__name">
<input class="form__field" name="name" id="name" :placeholder="$t('contatti.nomeForm')" required >
</div>
<div class="form__email">
<input class="form__field" type="email" name="email" id="email" placeholder="Email*" required >
</div>
<div class="form__upload">
<input class="form__field" type="file" name="fileToUpload" id="fileToUpload" accept=".doc, .docx, .pdf" required>
</div>
<div class="form__textarea">
<textarea class="form__field" name="message" id="message" :placeholder="$t('contatti.messaggioForm')" required></textarea>
</div>
<div class="form__privacy extra-mt">
<label><input type="checkbox" name="privacy" required> {{$t('contatti.privacy')}}</label>
</div>
<div class="form__send extra-mt">
<button class="default-button" type="submit" value="Invia" >{{$t('contatti.invia')}} </button>
</div>
</div>
</form>
</div>
</template>
<script>
export default {
mounted(){
const dis = this
const uploadField = document.getElementById("fileToUpload");
uploadField.onchange = function() {
if(this.files[0].size > 1048576){ // 1MB
alert(dis.$t('lavora.fileAlert'));
}
}
}
}
</script>
In the page "index.vue":
<template>
<div>
<div class="container">
<div class="first row extra-mt5-md is-center">
<div class="col-12 col-4-md text-center" style="padding: 2rem 0">
<h1>{{$t('lavora.title')}}</h1>
</div>
</div>
<div class="second row">
<div class="col-12 col-4-md image" />
<div class="col-12 col-8-md content">
<p>{{$t('lavora.p1')}}</p>
<TheFormJob class="extra-mt5" />
</div>
</div>
<div class="third row">
<div class="col-12">
<nuxt-link class="default-button-full" :to="localePath('contatti')">{{$t('contatti.title')}} → </nuxt-link>
</div>
</div>
</div>
</div>
</template>

Angular 4 form validation with input fields and checkboxes

I have this form right here:
<form (ngSubmit)="onSubmit()" #testForm="ngForm">
<div class="form-group col">
<label for="a">a</label>
<select class="form-control" id="a" [(ngModel)]="form.a" name="a" required>
<option value="x">x</option>
<option value="y">y</option>
</select>
</div>
<div class="form-group">
<label for="b">b</label>
<input class="form-control" id="b" [(ngModel)]="form.b" name="b" required />
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input">c
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input">d
</label>
</div>
<div class="col text-right">
<button type="submit" class="btn btn-success" [disabled]="!testForm.form.valid">Submit</button>
</div>
</form>
With this component-code behind:
export class FormComponent {
form = new Form();
submitted = false;
onSubmit() {
this.submitted = true;
}
}
What I want to achieve is that my button only gets enabled, when both the dropdown and the input field are filled in, which works with the required attribute, AND both checkboxes are checked, which doesn't work.
My question: Is there something like required for Checkboxes, or are there other ways to solve this problem?
Try this way:
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" [checked]="ch2" (change)="ch2= !ch2" class="form-check-input">c
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" [checked]="ch1" (change)="ch1= !ch1" class="form-check-input">d
</label>
</div>
<div class="col text-right">
<button type="submit" class="btn btn-success" [disabled]="!testForm.form.valid || !ch1 || !ch2">Submit</button>
</div>

Angular error:Form submission canceled because the form is not connected

What I am trying to do is -
I am trying to add a form to the existing form but the data not getting stored
what the error coming up -
in the console its showing form connection is missing.. how can I connect it with following code I have?
The code behind the click is something like this:
<button type="submit" class="btn btn-default" routerLink="../viewemployee" [disabled]="empForm.invalid">Add Employee</button>
please refer the link below for the code.. need help to move on from this to solve other tasks.
If it is required to post the code here as well, I will do.Please answer and respond.
Thanx in advance.
How to connect the form in angular routing
createemployee.component.html
<h2>Add Employee:</h2>
<form class="form-horizontal" #empForm="ngForm">
<div class="form-group">
<label class="control-label col-sm-2" for="name">Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="name" minlength="4" maxlength="10" pattern="^[A-Za-z0-9]*[A-Za-z0-9][A-Za-z0-9]\S*$" [(ngModel)]="model.name" placeholder="Enter Your Name"
#name="ngModel" required/>
<div *ngIf="name.invalid && (name.dirty || name.touched)" class="alert alert-danger">
<div *ngIf="name.errors.required">
Name is required.
</div>
<div *ngIf="name.errors.pattern">
No Spaces
</div>
<div *ngIf="name.errors.minlength">
Name must be at least 4 characters long.
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="position">Position:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="position" minlength="4" maxlength="10" pattern="^[a-z]*$" [(ngModel)]="model.position" placeholder="Enter your position"
#position="ngModel" required />
<div *ngIf="position.invalid && (position.dirty || position.touched)" class="alert alert-danger">
<div *ngIf="position.errors.required">
Position is required.
</div>
<div *ngIf="position.errors.pattern">
Only Alphabets are must be entered
</div>
<div *ngIf="position.errors.minlength">
Position must be at least 4 characters long.
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="salary">Salary:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="salary" pattern="[0-9]*"
minlength="5" maxlength="7" [(ngModel)]="model.salary" placeholder="Enter Salary" #salary="ngModel" required />
<div *ngIf="salary.invalid && (salary.dirty || salary.touched)" class="alert alert-danger">
<div *ngIf="salary.errors.required">
Salary is required.
</div>
<div *ngIf="salary.errors.minlength">
Salary must be in 5 numbers.
</div>
<div *ngIf="salary.errors.maxlength">
Salary must not be exceeded morethan 7 numbers.
</div>
<div *ngIf="salary.errors?.pattern">Only numebers should be typed
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default" routerLink="../viewemployee" [disabled]="empForm.invalid">Add Employee</button>
<button type="button" class="btn btn-default" routerLink="../home">Cancel</button>
</div>
</div>
</form>
You could change your component as follows:
Add event handler to the form:
<form (ngSubmit)="continue()">
Handle the routing in code:
continue() {
...
this.router.navigateByUrl("../viewemployee");
}
You need to inject the router:
constructor(private router: Router) {}

Form submit, Input:all() not showing all inputs

RESTfully, When I submit my form and return Input:all() in the Store method I'm getting only couple inputs not all of them!!
Can anyone help me here to find out why?
and advise me if I've to use Ajax all the time to submit forms, With example please!
Store method in the Controller:
/**
* Store a newly created HOTEL in DB.
*
* #return Response
*/
public function store(/*AddNewHotelRequest $addNewHotelRequest*/)
{
if(Request::ajax()) {
if ( Session::token() !== Input::get( '_token' ) ) {
return Response::json( array(
'msg' => 'Unauthorized attempt to create setting'
) );
}
$input = Request::all();
$response = [
'status' => 'success',
'input' => $input,
'msg' => 'Hotel created successfully',
];
return Response::json( $response );
}
// return Input::all(); //with Request::all() same output
}
Form from view "create new hotel"
{!! Form::open([ 'data-remote' ,'method'=>'POST', 'action' => 'HotelsController#store', 'class' => 'panel form-horizontal','id'=>'hotelForm']) !!}
<input id="myToken" type="hidden" name="_token" value="{{ csrf_token() }}" />
<script> var _CSRT_token = "{{ csrf_token() }} " ;</script>
<div class="panel-heading">
<span class="panel-title">Adding New Hotel</span>
</div>
<div class="panel-body">
<!-- / .form-group of Errors -->
<div class="form-group">
<div class="col-sm-12">
#include('errors.list')
</div>
</div>
<!-- Hotel Name -->
<div class="form-group">
<label for="hotel_name" class="col-sm-2 control-label">Hotel name *</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="hotel_name" name="hotel_name" placeholder="Hotel name">
</div>
<p class="label label-warning label-tag">Name should be in English</p>
</div>
<!-- / .form-group of hotel_details -->
<div class="form-group">
<label for="hotel_details" class="col-sm-2 control-label">Hotel Details</label>
<div class="col-sm-8">
<textarea class="form-control" id="hotel_details" placeholder="Short description, General information or Some Details about this Hotel" rows="3"></textarea>
</div>
<p class="label label-warning label-tag">Details should be in English</p>
</div>
<!-- Hotel website -->
<div class="form-group">
<label for="hotel_website" class="col-sm-2 control-label">Website *</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="hotel_website" name="hotel_website" placeholder="http://">
</div>
</div>
<!-- / .form-group of rank -->
<div class="form-group">
<label for="rank" class="col-sm-2 control-label">Rank</label>
<div class="col-sm-1">
<input type="text" class="form-control" id="rank" placeholder="Boutique or 4">
</div>
</div>
<div class="panel colourable">
<div class="panel-body">Prices</div>
<!-- / .form-group of single_price -->
<div class="form-group">
<label for="single_price" class="col-sm-2 control-label">Single price</label>
<div class="input-group col-sm-1">
<span class="input-group-addon">€</span>
<input type="text" class="form-control room-price-group" id="single_price">
<span class="input-group-addon">.00</span>
</div>
</div>
<!-- / .form-group of double_price -->
<div class="form-group">
<label for="double_price" class="col-sm-2 control-label">Double price</label>
<div class="input-group col-sm-1">
<span class="input-group-addon">€</span>
<input type="text" class="form-control room-price-group" id="double_price">
<span class="input-group-addon">.00</span>
</div>
</div>
<!-- / .form-group of extra_bed_price -->
<div class="form-group">
<label for="extra_bed_price" class="col-sm-2 control-label">Extra Bed price</label>
<div class="input-group col-sm-1">
<span class="input-group-addon">€</span>
<input type="text" class="form-control" id="extra_bed_price">
<span class="input-group-addon">.00</span>
</div>
</div>
</div>
<div class="form-group">
<label for="facilities" class="col-sm-2 control-label">Facilities *</label>
<div class="col-sm-10">
<select id="facilities" class="col-sm-8 form-controljs-example-basic-multiple" name="facilities" multiple="multiple">
<optgroup label="Free">
#foreach($facilities as $facility)
#if(!$facility->is_surcharge)
<option class="" value="{{ $facility->id }}">{{ $facility->name }}</option>
#endif
#endforeach
</optgroup>
<optgroup label="Surcharge">
#foreach($facilities as $facility)
#if($facility->is_surcharge)
<option value="{{ $facility->id }}">{{ $facility->name }}</option>
#endif
#endforeach
</optgroup>
</select>
</div>
</div>
<div class="panel colourable">
<div class="panel-body">Address</div>
<!-- / .form-group of Country -->
<div class="form-group">
<label for="country" class="col-sm-2 control-label">Country *</label>
<div class="col-sm-2">
<select id="country" class="form-control" name="country" >
<option></option>
#foreach($countries as $country)
<option value="{{ $country->id }}" phone_code="{{ $country->phone_code }}" >{{ $country->name }}</option>
#endforeach
</select>
<p class="help-block helperQuote">Begin by choosing your country.</p>
</div>
</div>
<!-- / .form-group of Region -->
<div class="form-group">
<label for="region" class="col-sm-2 control-label">Region *</label>
<div class="col-sm-2">
<select id="region" class="form-control" name="region">
</select>
</div>
</div>
<!-- / .form-group of city -->
<div class="form-group">
<label for="city" class="col-sm-2 control-label">City *</label>
<div class="col-sm-2">
<select id="city" class="form-control" name="city">
</select>
</div>
</div>
<!-- / .form-group of rank -->
<div class="form-group">
<label for="zip" class="col-sm-2 control-label">Zip Code</label>
<div class="col-sm-1">
<input type="text" class="form-control" id="zip" placeholder="34600">
</div>
</div>
<!-- / .form-group of city -->
<div class="form-group">
<label for="address" class="col-sm-2 control-label">Hotel Address *</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="address" placeholder="Street name, number of building floor ...etc">
</div>
{{--<p class="label label-warning label-tag">Address should be in English</p>--}}
</div>
<!-- / .form-group of map -->
{{--GOOGLE MAPS--}}
<div class="form-group">
<label for="map" class="col-sm-2 control-label">Location *</label>
{{--Initialize Map--}}
<div class="col-sm-9">
<div id="map-canvas" class="" style="width: 100%; height: 350px !important;">
</div>
<p id="markerPosition" class="help-block"><i>Drag the pin to the position of the hotel </i></p>
<p id="lat" class="help-block">Latitude: 41.0694</p>
<p id="lng" class="help-block">Longitude: 29.0043</p>
<input id="latitude" type="hidden" value="37.7577">
<input id="longitude" type="hidden" value="-122.4376">
</div>
</div>
</div> <!-- End of Address Panel -->
<!-- Hotel tel -->
<div class="form-group">
<label for="country_code" class="col-sm-2 control-label">Country Code *</label>
<div class="col-sm-1">
<input type="text" class="form-control" id="country_code" name="country_code" placeholder="+90">
</div>
<label for="country_code" class="col-sm-1 control-label">Phone *</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="phone" name="phone" placeholder="(___) ___-____">
</div>
<label for="extension" class="col-sm-1 control-label">Extension</label>
<div class="col-sm-1">
<input type="text" class="form-control" id="extension" name="extension" placeholder="3">
</div>
</div>
<ht/>
<!-- / .form-group of status -->
<div class="form-group">
<label for="status" class="col-sm-2 control-label">Status *</label>
<div class="col-sm-2">
<select id="status" class="form-control" name="status" >
<option value="0">Suspended</option>
<option value="1" selected>Draft</option>
<option value="2">Published</option>
</select>
<p class="help-block helperQuote"><strong>Suspended:</strong>Trash,<strong>Draft:</strong>Default,<strong>Published:Online</strong></p>
</div>
<p class="label label-warning label-tag">Only Published Hotels will be online!</p>
</div>
{{--#if (Auth::user()->isAdmin())--}}
<!-- / .form-group of publisher -->
<div class="form-group">
<label for="publisher" class="col-sm-2 control-label">Publisher *</label>
<div class="col-sm-2">
<select id="publisher" class="form-control" name="publisher" >
#foreach($publishers as $publisher)
<option value="{{ $publisher->id }}">{{ $publisher->name }} ({{$publisher->type}}) </option>
#endforeach
</select>
</div>
</div>
{{--#endif--}}
<div class="form-group" style="margin-bottom: 0;">
<div class="col-sm-offset-2 col-sm-1">
<button type="submit" class="btn btn-lg btn-primary btn-flat"><span class="btn-label icon fa fa-plus-circle"></span> Add Hotel</button>
</div>
<div id="loader" class="col-sm-1" style="display: none;"><img src="/assets/images/plugins/bootstrap-editable/loading.gif" alt="loading regions" /></div>
</div> <!-- / .form-group -->
</div>
{!! Form::Close() !!}
The output is like this:
{"_token":"PWKknjx5S9u8m98ApGDXYKqaTyF7aFZDaye9uYPm","hotel_name":"City Loft","hotel_website":"http:\/\/www.cityloft.com.tr\/","facilities":"23","country":"6","region":"3344950","city":"783593","country_code":"+355","phone":"(123) 123-1231","extension":"3123","status":"1","publisher":"1"}
you forgot name attribute for Hotel Detail and Price and might be more
<textarea class="form-control" **name="hotel_detail"** id="hotel_details" placeholder="Short description, General information or Some Details about this Hotel" rows="3"></textarea>