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>
Related
I'm facing a problem with bootstrap 4 form validation feedback error. I'd like to have the label to change color instead of the invalid-feedback div to appear under the input field. Please how can I achieve my goal? Below there's the form I'm using and boostrap version is 4.5.
Thanks a lot for any help you can give me.
enter code here
<div class="row">
<div class="col-md-12"><!--Grid column-->
<div class="myeditform">
<form action="page.asp" id="add-form" class="add-form" method="post" novalidate>
<input type="hidden" id="action" name="action" value="addnew">
<div class="row">
<div class="col-md-8">
<div class="md-form mb-0">
<label for="ev_title">Title *</label>
<input type="text" class="form-control" name="ev_title" id="ev_title" placeholder="Title ..." required="required">
<div class="invalid-feedback">This field is required</div>
</div>
</div>
<div class="col-md-4">
<div class="md-form mb-0">
<label for="ev_is_active">Status</label>
<select class="browser-default form-control" id="ev_is_active" name="ev_is_active">
<option value="true">ON LINE</option>
<option value="false">OFF LINE</option>
</select>
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="col-md-6">
<div class="md-form mb-0">
<label for="ev_at_place">Location *</label>
<input type="text" class="form-control" name="ev_at_place" id="ev_at_place" placeholder="Location ..." required="required">
<div class="invalid-feedback">This field is required</div>
</div>
</div>
<div class="col-md-3">
<div class="md-form mb-0">
<label for="ev_dance_type">Evening of *</label>
<select class="browser-default form-control" id="ev_dance_type" name="ev_dance_type" required="required">
<option value="">Seleziona...</option>
<option value="op1">op1</option>
<option value="op2">op2</option>
<option value="op3">op3</option>
<option value="op4">op4</option>
<option value="op5">op5</option>
<option value="op6">op6</option>
<option value="other">other</option>
</select>
<div class="invalid-feedback">This field is required</div>
</div>
</div>
<div class="col-md-3">
<div class="md-form mb-0">
<label for="ev_cycle">Frequency *</label>
<select class="browser-default form-control" id="ev_cycle" name="ev_cycle" required="required">
<option value="">Seleziona...</option>
<option value="7">7</option>
<option value="14">14</option>
<option value="21">21</option>
<option value="28">28</option>
<option value="0">One time off</option>
</select>
<div class="invalid-feedback">This field is required</div>
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="col-md-12">
<div class="md-form mb-0">
<label for="ev_description">Description *</label>
<textarea class="form-control" name="ev_description" id="ev_description" rows="10" placeholder="Description required ..." required="required"></textarea>
<script>
CKEDITOR.replace( 'ev_description');
</script>
<div class="invalid-feedback">This field is required</div>
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="col-md-12">
<div class="md-form mb-0">
<label for="ev_notes">Note</label>
<input type="text" class="form-control" name="ev_notes" id="ev_notes" placeholder="Es. ...">
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="col-md-12">
<div class="md-form mb-0">
<button type="button" class="btn btn-primary mybtn float-left" onclick="history.go(-1)">Back</button>
<button type="reset" class="btn btn-warning mybtn float-left">Reset</button>
<button type="submit" class="btn btn-primary float-right" >Add</button>
</div>
</div>
</div><!-- row -->
</form>
</div> <!--myedit form-->
</div><!--Grid column-->
We are trying to manage to get a simple contact form running. But regardless of what we try, we get nothing at all.
The form itself is on the front-end and configured like this :
<f:section name="Main">
<div class="ext-frame container">
<h2>{record.header}</h2>
<f:form action="submit" name="order" object="{order}" class="form-horizontal">
<f:for each="{settings.offer}" as="obj" key="id">
<div class="row offer">
<f:if condition="{obj.offer.img}">
<f:then>
<div class="col-sm-4 col-md-4 offer-img-container">
<img src="../{obj.offer.img}" class="offer-image" alt="{obj.offer.img.alternative}" />
</div>
</f:then>
</f:if>
<div class="col-sm-8 col-md-8 {f:if(condition: '{obj.offer.img} == \'\'', then: 'col-sm-offset-4 col-md-offset-4')}">
<label class="offer-label">
<f:form.radio property="offer" value="{id}" />
<div class="pull-right">
<p class="lead">
{obj.offer.title}<br/>
<small>{obj.offer.subtitle}</small>
</p>
<p class="small">{obj.offer.description}</p>
</div>
</label>
</div>
</div>
<hr />
</f:for>
<div class="form-group row">
<label for="salut" class="col-sm-3 control-label">Anrede*</label>
<div class="col-sm-5">
<f:form.select property="salut" options="{herr: 'Herr', frau: 'Frau'}" class="form-control" />
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-3 control-label">Vorname*</label>
<div class="col-sm-5">
<f:form.textfield property="name" value="" class="form-control" />
</div>
</div>
<div class="form-group row">
<label for="surname" class="col-sm-3 control-label">Nachname*</label>
<div class="col-sm-5">
<f:form.textfield property="surname" value="" class="form-control" />
</div>
</div>
<div class="form-group row">
<div class="col-sm-3 cusnr">
<label for="cusNr" class="control-label">Kundennummer</label>
<span id="helpBlock" class="help-block">(wenn bekannt)</span>
</div>
<div class="col-sm-5">
<f:form.textfield property="cusNr" value="" class="form-control" />
</div>
</div>
<div class="form-group row">
<label for="addr" class="col-sm-3 control-label">Straße/Hausnr.*</label>
<div class="col-sm-5">
<f:form.textfield property="addr" value="" class="form-control" />
</div>
</div>
<div class="form-group row">
<label for="zip" class="col-sm-3 control-label">PLZ*</label>
<div class="col-sm-3">
<div class="input-group">
<span class="input-group-addon">D-</span>
<f:form.textfield property="zip" value="" class="form-control" type="number" maxlength="5" />
</div>
</div>
</div>
<div class="form-group row">
<label for="city" class="col-sm-3 control-label">Ort*</label>
<div class="col-sm-5">
<f:form.textfield property="city" value="" class="form-control" />
</div>
</div>
<div class="form-group row">
<label for="mail" class="col-sm-3 control-label">E-Mail*</label>
<div class="col-sm-5">
<f:form.textfield property="mail" value="" class="form-control" type="email" />
</div>
</div>
<div class="form-group row">
<label for="phone" class="col-sm-3 control-label">Telefon</label>
<div class="col-sm-5">
<f:form.textfield property="phone" value="" class="form-control" type="tel" />
</div>
</div>
<div class="form-group row"><div class="col-sm-offset-3 col-sm-5">
<f:form.select property="know" options="{
0: 'a?*',
1: 'a',
2: 'b',
3: 'c',
4: 'd',
5: 'e',
6: 'f',
7: 'g'
}" class="form-control" />
</div></div>
<div class="form-group row">
<div class="col-sm-offset-3 col-sm-9">
<div class="checkbox">
<label>
<f:form.checkbox name="term" value="1" />
Ich habe die AGB gelesen und erkläre mich mit
ihnen einverstanden. Ich wurde über mein <a href="widerruf.php" target="_blank">
Widerrufsrecht</a> informiert.
</label>
</div>
</div>
</div>
<div class="form-group row">
<f:form.submit name="submit" value="Send" class="col-xs-12 col-sm-5 col-sm-offset-3 btn" />
</div>
</f:form>
</div>
</f:section>
In our ContentController.php there is also a submitAction given but it seems that this Action is never called :
public function submitAction() {
echo 'Testoutput';exit;
}
Where does the form lead you after submitting? Check out the final HTML action="" if everything is correct.
Try to set the form "method" to POST. I've just had some problems with forms using GET because the target PID got lost for unknown reasons so I had to add a <input type="hidden" name="id" value="{targetPid}" /> to get it working.
I have grouped 3 inputs in one line (bootply)
<div class="container">
<div class="row">
<div class="form-group has-warning">
<label for="inputName" class="col-lg-2 col-sm-3 control-label">name</label>
<div class="col-md-2 col-sm-2">
<input type="text" class="form-control" placeholder="name" name="order">
</div>
<label for="inputWarning1" class="col-lg-1 col-sm-3 control-label">quantity</label>
<div class="col-md-2 col-sm-2">
<input type="number" class="form-control " placeholder="quantity" name="quantity" id="inputWarning1">
</div>
<label for="inputName" class="col-lg-1 col-sm-3 control-label">####</label>
<div class="col-md-2 col-sm-2">
<input type="number" class="form-control" placeholder="AA" name="packetNumber">
</div>
</div>
</div>
</div>
and I want only the input with quantity has the color of the class has-warning. Is there a way to do that by keeping 3 inputs in one line?
Just remove has-warning class from the div which has class form-group and put a separate div above the quantity lable like below:
<div class="container">
<div class="row">
<div class="form-group">
<label for="inputName" class="col-lg-2 col-sm-3 control-label">name</label>
<div class="col-md-2 col-sm-2">
<input type="text" class="form-control" placeholder="name" name="order">
</div>
<div class="has-warning">
<label for="inputWarning1" class="col-lg-1 col-sm-3 control-label">quantity</label>
<div class="col-md-2 col-sm-2">
<input type="number" class="form-control " placeholder="quantity" name="quantity" id="inputWarning1">
</div>
</div>
<label for="inputName" class="col-lg-1 col-sm-3 control-label">####</label>
<div class="col-md-2 col-sm-2">
<input type="number" class="form-control" placeholder="AA" name="packetNumber">
</div>
</div>
</div>
</div>
Edited Code In Bootply
Check It.
I'd like to create a long form that is just all one form instead of a bunch of separate forms. Is this doable? I've reviewed all the Bootstrap Documentation and this seems to be the only way to do it. Does anyone know a way around this? Below is what I have, every field is a separate form, and I need it to be one.
<div class="row-container">
<div class="row">
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="claimnumber">Claim Number</label>
<input type="text" class="form-control" id="claimnumber" placeholder="">
</div>
</form>
</div>
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="insuredid">Insured ID</label>
<input type="text" class="form-control" id="insuredid" placeholder="">
</div>
</form>
</div>
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="claimnumber">Patient ID</label>
<input type="text" class="form-control" id="patientid" placeholder="">
</div>
</form>
</div>
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="lastname">Patient Last Name</label>
<input type="text" class="form-control" id="lastname" placeholder="">
</div>
</form>
</div>
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="lastname">Patient Last Name</label>
<input type="text" class="form-control" id="Text1" placeholder="">
</div>
</form>
</div>
</div>
</div>
<div class="datecontainer">
<div class="date1container">
<div class="dateheading">Service Date</div>
<div class="datebody">
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="lastname">Start</label>
<input type="text" class="form-control calendar" id="date" placeholder="00/00/0000">
</div>
</form>
</div>
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="lastname">End</label>
<input type="text" class="form-control calendar2" id="date2" placeholder="00/00/0000">
</div>
</form>
</div>
</div>
</div>
<div class="date2container">
<div class="dateheading">Import Date</div>
<div class="datebody">
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="lastname">Start</label>
<input type="text" class="form-control calendar3" id="date3" placeholder="00/00/0000">
</div>
</form>
</div>
It works with just one form... check this
http://jsfiddle.net/7LChZ/1/show/
<div class="container">
<form class="form-inline">
<div class="row-container">
<div class="row">
<div class="field-wrapper">
<div class="form-group">
<label for="claimnumber">Claim Number</label>
<input type="text" class="form-control" id="claimnumber" placeholder="" />
</div>
</div>
<div class="field-wrapper">
<div class="form-group">
<label for="insuredid">Insured ID</label>
<input type="text" class="form-control" id="insuredid" placeholder="" />
</div>
</div>
<div class="field-wrapper">
<div class="form-group">
<label for="claimnumber">Patient ID</label>
<input type="text" class="form-control" id="patientid" placeholder="" />
</div>
</div>
<div class="field-wrapper">
<div class="form-group">
<label for="lastname">Patient Last Name</label>
<input type="text" class="form-control" id="lastname" placeholder="" />
</div>
</div>
<div class="field-wrapper">
<div class="form-group">
<label for="lastname">Patient Last Name</label>
<input type="text" class="form-control" id="Text1" placeholder="" />
</div>
</div>
</div>
</div>
<div class="datecontainer">
<div class="date1container">
<div class="dateheading">Service Date</div>
<div class="datebody">
<div class="field-wrapper">
<div class="form-group">
<label for="lastname">Start</label>
<input type="text" class="form-control calendar" id="date" placeholder="00/00/0000" />
</div>
</div>
<div class="field-wrapper">
<div class="form-group">
<label for="lastname">End</label>
<input type="text" class="form-control calendar2" id="date2" placeholder="00/00/0000" />
</div>
</div>
</div>
</div>
<div class="date2container">
<div class="dateheading">Import Date</div>
<div class="datebody">
<div class="field-wrapper">
<div class="form-group">
<label for="lastname">Start</label>
<input type="text" class="form-control calendar3" id="date3" placeholder="00/00/0000" />
</div>
</div>
</div>
</div>
</div>
</form>
</div>
What I change is, I remove all form tags and wrap them all with just one.
You should only use one <form> -tag and not multiple ones if you only need one form. You should place it after <div class="row">. And don't forget to close it correctly!
I'm trying to insert a new branch for distributor data to pass to Sinatra. It's able to insert a new record but this error is produced:
"ERROR Rack::Lint::LintError: body yielded non string value [:disBranchID, 27]"
disBranchID is the primary key of the table and it's set to auto increment.
The HTML looks like this:
<form name="add_dis_branch_form" action="/add_dis_branch" method="post" id="disB" enctype="multipart/form-data">
<div class="input-group">
<span class="input-group-addon"> Brand </span>
<select id="disSlcMan" class="btn btn-default full-width" name="disID" ng-model="disB.disID" required>
<option value="">Select Brand</option>
<% AutoMobile::DB[:distributor].select(:disID, :disComName).each do |dis| %>
<option value="<%= dis[:disID]%>"><%= dis[:disComName] %></option>
<% end %>
</select>
</div>
<br>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-map-marker"></i> Address</span>
<input type="text" class="form-control" name="address" placeholder="Address" required ng-model="disB.address" >
</div>
<br>
<div class="row">
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon"> City </span>
<input type="text" class="form-control" name="city" placeholder="Petaling Jaya" required ng-model="disB.city">
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon"> State </span>
<input type="text" class="form-control" name="state" placeholder="Selangor" required ng-model="disB.state">
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon"> Zip </span>
<input type="text" class="form-control" name="zip" placeholder="47800" required ng-model="disB.zip" ng-pattern="/^\d{5}$/">
</div>
<span ng-show="add_dis_branch_form.zip.$error.pattern" class="help-inline">Invalid zip code</span>
</div>
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon" title="Map"><i class="fa fa-map-marker"></i></span>
<button id="btMap" class="btn btn-success form-control" onclick="return false;">Find Your Location</button>
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon"> Latitude </span>
<input type="text" class="form-control" id="disLat" name="latitude" required ng-model="disB.latitude" >
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon"> Longitude </span>
<input type="text" class="form-control" id="disLong" name="longitude" required ng-model="disB.longitude" >
</div>
</div>
</div>
<small>
<b class="help-inline">
Click Find Your Location button to locate your address.
</b>
</small>
<br>
<div class="row">
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-phone"></i> Phone</span>
<input type="text" class="form-control" name="phoneNo" placeholder="03-12345432" required ng-model="disB.phoneNo" ng-pattern="/^0[0-9]{1}-[0-9]{8}$/">
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-print"></i> Fax </span>
<input type="text" class="form-control" name="faxNo" placeholder="03-12345432" required ng-model="disB.faxNo" ng-pattern="/^0[0-9]{1}-[0-9]{8}$/">
</div>
</div>
</div>
<br>
<div class="pull-right">
<input type="submit" class="btn btn-success" ng-disabled="!canSave('add_dis_branch_form')">
</div>
</form> <!-- end form -->
The Sinatra code:
add_dis_branch = lambda do
newBranch = AutoMobile::DisBranch.new
newBranch.address = params[:address]
newBranch.city = params[:city]
newBranch.state = params[:state]
newBranch.zip = params[:zip]
newBranch.phone = params[:phoneNo]
newBranch.fax = params[:faxNo]
newBranch.latitude = params[:latitude]
newBranch.longitude = params[:longitude]
newBranch.disID = params[:disID]
newBranch.save
end
Here is one way you could write the route:
post "/automobile/branch" do
newBranch = AutoMobile::DisBranch.new
newBranch.address = params[:address]
newBranch.city = params[:city]
newBranch.state = params[:state]
newBranch.zip = params[:zip]
newBranch.phone = params[:phoneNo]
newBranch.fax = params[:faxNo]
newBranch.latitude = params[:latitude]
newBranch.longitude = params[:longitude]
newBranch.disID = params[:disID]
newBranch.save
halt 201
end
but I suggest you take a good read of the documentation for Sinatra on creating routes and for Sequel on creating model instances.