Livewire old values for dynamic arrays as part of a parent form - laravel-livewire

I'm working with livewire and need to preserve old values of a dynamic array (add/delete fields), inserted as a subform, when validation fails from another part of the form.

I need to preserve data already entered in the inputs, by means of an inserted livewire block, when a field of the container form fails in the validation. It turns out that when you return, the data entered in the livewire form is lost. Thanks for your help!
The place where I insert livewire tag...
...
<div class="form-group row">
<label for="numbers_per_line"
class="col-md-4 col-form-label text-md-right">
{{ __('Cantidad de números por línea (9 o 10)') }}
</label>
<div class="col-md-6">
<input class="form-control"
type="number" min="9" max="10"
name="numbers_per_line"
value="{{ old('numbers_per_line') ??
$bingo->numbers_per_line }}"
required>
</div>
</div>
#livewire('bingo-draw', ['bingo' => $bingo])
<div class="form-group row">
<label for="card_price"
class="col-md-4 col-form-label text-md-right">
{{ __('Precio del cartón') }}
</label>
<div class="col-md-6">
<input class="form-control"
type="number" min="1.00"
step="0.01" name="card_price"
value="{{ old('card_price') ?? $bingo->card_price }}"
required>
</div>
</div>
...
The code of livewire inserted is the following:
<div>
<div class="form-group row">
<label for="number_of_draws"
class="col-md-4 col-form-label text-md-right">
{{ __('Cantidad de premios en el sorteo final') }}
</label>
<div class="col-md-6">
<input class="form-control" type="number" min="1"
name="number_of_draws"
wire:model="numberOfDraws"
value="{{ old('number_of_draws') ??
$numberOfDraws }}"
required readonly="" disabled="true">
</div>
</div>
<div class="form-group row">
<div class="col-md-12">
<table class="table table-auto w-full">
<thead>
<th class="col-md-1 text-left">Nro. Sorteo</th>
<th class="col-md-7 text-left">Descripción</th>
<th class="col-md-2 text-left">
Valor del premio en pesos</th>
<th class="col-md-2 text-left" width="100"></th>
</thead>
<tbody>
#php $i = 0; #endphp
#foreach($drawsArray as $drawElement)
<tr>
<td class="p-1" valign="top">
<input class="form-control" type="number"
min="1" name="draw_number[]"
value="{{ old('draw_number.'.$i)
??
$drawElement['draw_number']
}}"
required readonly />
</td>
<td class="p-1" valign="top">
<textarea class="md-textarea form-control"
name="draw_description[]"
rows="2" required
>{{ old('draw_description.'.$i) ??
$drawElement['draw_description'] }}
</textarea>
</td>
<td class="p-1" valign="top">
<input class="form-control" type="text"
name="draw_prize[]"
value="{{ old('draw_prize.'.$i) ??
$drawElement['draw_prize']
}}"
required />
</td>
<td class="p-1" valign="top">
<button wire:click="removeDraw({{
$drawElement['draw_number'] }})"
type="button"
class="btn btn-warning">
Eliminar
</button>
</td>
</tr>
#php $i++; #endphp
#endforeach
</tbody>
</table>
</div>
<div class="form-group row">
<div class="col-md-6 offset-md-1">
#error('newDescription')
<div class="alert alert-danger" role="alert">
{{ $message }}
</div>
#enderror
<textarea class="md-textarea form-control"
name="new_description"
rows="2" wire:model.lazy="newDescription"
placeholder="Ingrese nuevo premio...">
</textarea>
</div>
<div class="col-md-3">
#error('newPrize')
<div class="alert alert-danger" role="alert">
{{ $message }}
</div>
#enderror
<input class="form-control" type="text"
name="new_prize"
placeholder="Importe..."
wire:model.lazy="newPrize">
</div>
<div class="col-md-2">
<button wire:click="addDraw"
type="button" class="btn btn-success">
Agregar premio
</button>
</div>
</div>
</div>
</div>
And finally, the code of the mount function:
public function mount(Bingo $bingo){
$this->numberOfDraws = old('numberOfDraws') ??
$bingo>number_of_draws;
$this->draws = $bingo->draws;
$this->currentBingo = $bingo;
if(old('numberOfDraws')){
for($i = 0; $i <= $this->numberOfDraws; $i++){
$this->drawsArray[] = [
'draw_number' => old('draw_number.'.$i),
'draw_description' => old('draw_description.'.$i),
'draw_prize' => old('draw_prize.'.$i),
];
}
}else{
foreach($this->draws as $draw){
$this->drawsArray[] = [
'draw_number' => $draw->draw_number,
'draw_description' => $draw->description,
'draw_prize' => $draw->prize,
];
}
}
}
The function addDraw keeps the values of draw_number in order, but if the validation fails I lost the old values...
I apologize if I'm not clear enough... my english is not very well, and is the first time I post some question here.
Thanks!

Related

Only the first form in Django forloop submitting data. The other forms submit empty fields

I am facing a situation whereby only the first form in the forloop in the code below can submit data. The rest of the forms after the first forloop posts empty data. What could be the problem. I believe my views is good since it's able to process the data from the first form. I believe the problem should be in the code below only that i cannot figure where the issue is
When i hit submit button on the subsequent form i get the following in the shell
[12/Mar/2020 12:07:17] "POST /hotels/conference/cart/twiga-boardroom-3/ HTTP/1.1" 302 0
[12/Mar/2020 12:07:18] "GET /hotels/conference/panari-hotel HTTP/1.1" 200 34389
HTML CODE
{% for item in object.conferenceroom_set.all %}
<div class="room-item">
<div class="row gap-20">
<div class="col-12 col-sm-12 col-md-6">
<div class="row gap-20">
<div class="col-12 col-sm-4 col-md-4">
<div class="image">
<img src="{{ item.room_photo.url }}" alt="{{ item.object.name }}" />
</div>
<p></p>
{% if user.is_authenticated and item.user == user %}
Edit
Delete
{% endif %}
</div>
<div class="col-12 col-sm-12 col-md-8">
<div class="content">
<h5>{{ item.room_Name }}</h5>
<p>{% for list in item.features_as_list %}
<span class="icon-font"><i class="fas fa-check-circle text-primary"></i> {{ list }} </br></span> {% endfor %}</p>
<p class="max-man">Max. Guests : <span class="badge badge-primary">{{ item.room_Capacity }}</span>
<p class="price"><span class="number text-secondary"><small>Ksh</small>{{ item.room_Price|intcomma }}</span> per guest</p>
</div>
</div>
</div>
</div>
<div class="col-12 col-md-6" >
<div class="row gap-20 justify-content-between">
<form method="POST" action="{% url 'conference-update-booking-2' item.slug %}" class='pull-right'>
<div id="airDatepickerRange-general" class="col-12 col-sm-8 col-md-8">
<div class="form-group">
<label class="line12 font13 spacing-05 mt-5 mb-10 block">Check-in</label>
<div class="form-icon-left">
<span class="icon-font text-muted"><i class="bx bx-calendar"></i></span>
<input type="text" name='checkin'id="dateStart-general" class="form-control form-readonly-control" placeholder="dd/mm/yyyy">
</div>
</div>
<div class="form-group">
<label class="line12 font13 spacing-05 mt-5 mb-10 block">Check-out</label>
<div class="form-icon-left">
<span class="icon-font text-muted"><i class="bx bx-calendar"></i></span>
<input type="text" name='checkout' id="dateEnd-general" class="form-control form-readonly-control" placeholder="dd/mm/yyyy">
</div>
</div>
</div>
<div class="col-12 col-sm-4 col-md-4">
<div class="form-group form-spin-group mb-5">
<label class="line12 font13 spacing-05 mt-5 mb-10 block">Attendants</label>
<div class="form-icon-left">
<span class="icon-font"><i class="dripicons-user text-muted"></i></span>
<input name='qty' class="form-control touch-spin-03 form-readonly-control" value="1" readonly/>
</div>
<label class="line12 font13 spacing-05 mt-5 mb-10 block">Reserve</label>
<label class="line12 font13 spacing-05 mt-5 mb-10 block"></label>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-sm btn-block" data-toggle="modal" data-target="#exampleModal2">
Book
</button>
<!-- Modal -->
<div class="modal" id="exampleModal2" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel2" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel2">Book Accomodation</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="col-12" style="padding-left:0px">
<input type="checkbox" id="myCheck" onclick="myFunction()"> Do you also wish to book rooms for your guests' stay?
<p></p>
<p></p>
<p></p>
</div>
<div class="row" id="text" style="display:none">
<div class="row gap-20 gap-lg-30 mb-20">
<div class="col-8">
<div class="form-group mb-0" style="padding-left:15px">
<select class="custom-select custom-select-md" name="single_hotel_room">
<option selected="" disabled>Select Single room</option>
{% for room in object.room_set.all %}
<option>{{ room.id}}-{{ room.room_Type}}#{{ room.room_Price}}</option>
{%endfor %}
</select>
</div>
</div>
<div class="col-4">
<div class="form-group mb-10" style="padding-right:15px">
<div class="form-icon-left">
<span class="icon-font"><i class="dripicons-user text-muted"></i></span>
<input name='single-guests' class="form-control touch-spin-03 form-readonly-control" value=""/>
</div><label class="line12 font13 spacing-05 mt-5 mb-10 block">Guests</label>
</div>
</div>
</div>
<div class="row gap-20 gap-lg-30 mb-20">
<div class="col-8">
<div class="form-group mb-0" style="padding-left:15px">
<select class="custom-select custom-select-md" name="double_hotel_room">
<option selected="" disabled>Select Double room</option>
{% for room in object.room_set.all %}
<option>{{ room.id}}-{{ room.room_Type}}#{{ room.room_Price}}</option>
{%endfor %}
</select>
</div>
</div>
<div class="col-4">
<div class="form-group mb-10" style="padding-right:15px">
<div class="form-icon-left">
<span class="icon-font"><i class="dripicons-user text-muted"></i></span>
<input name='double-guests' class="form-control touch-spin-03 form-readonly-control" value=""/>
</div><label class="line12 font13 spacing-05 mt-5 mb-10 block">Guests</label>
</div>
</div>
</div>
<div class="row gap-20 gap-lg-30 mb-20">
<div class="col-8">
<div class="form-group mb-0" style="padding-left:15px">
<input type="date" id="checkindate" name="checkindate" class="form-control form-readonly-control">
<label class="line12 font13 spacing-05 mt-5 mb-10 block">CheckIn Date</label>
</div>
</div>
<div class="col-4">
<div class="form-group mb-10" style="padding-right:15px">
<div class="form-icon-left">
<span class="icon-font"><i class="dripicons-user text-muted"></i></span>
<input name='nights' class="form-control touch-spin-03 form-readonly-control" value=""/>
</div><label class="line12 font13 spacing-05 mt-5 mb-10 block">Nights</label>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-sm btn-block">Continue</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% csrf_token %}
</form>
{% endfor %}```
I want to answer this question myself so that if there will be any newbie who will face this problem will get a solution here. Only the first form in the forloopwould submit or post data because i was using the same name for the modal div id tag. I modified my code above by generating unique modal div id. To do this i added {{forloop.counter}} to id="exampleModalLabel. This ensured that every autogenerated modal would be generated with unique div id tag. I hope this helps someone. Thanks

How generate a DOC and a PDF from html <div> in Django

Good day,
In Django project I have an html file with a div in which some fields(like p) change the content by radiobutton choice (using JavaScript).
Need to turn the div with the changed content (by radiobutton choice) into pdf and doc (with saving of all styles).
Any help is appreciated.
I tried "wkhtmltopdf" but it generates pdf only with model contents from db and without result of radiobutton work.
<!--Choice radiobuttons-->
function Display(obj) {
fioid=obj.id;
if(fioid=='exampleRadios1'){
document.getElementById("fiz").style.display='block';
document.getElementById("ip").style.display='none';
document.getElementById("ur").style.display='none';
} else if(fioid=='exampleRadios2'){
document.getElementById("ip").style.display='block';
document.getElementById("fiz").style.display='none';
document.getElementById("ur").style.display='none';
} else if(fioid=='exampleRadios3'){
document.getElementById("ur").style.display='block';
document.getElementById("fiz").style.display='none';
document.getElementById("ip").style.display='none';
}}
<div class="col-12">
<div class="form-check">
<input class="form-check-input" type="radio" name="exampleRadios"
id="exampleRadios1" value="FIZ" onclick="Display(this);" checked>
<label class="form-check-label" for="exampleRadios1">
FIZ
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="exampleRadios"
id="exampleRadios2" value="IP" onclick="Display(this);">
<label class="form-check-label" for="exampleRadios2">
IP
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="exampleRadios"
id="exampleRadios3" value="UR" onclick="Display(this);">
<label class="form-check-label" for="exampleRadios3">
UR
</label>
</div>
</div>
<div>
<p style="text-align: justify; font-family: Times New Roman;">
<span style='display: block;' id="fiz">This is FIZ</span>
<span style='display: none;' id="ip">This is IP</span>
<span style='display: none;' id="ur">This is UR</span>
</p>
<div>
This is may be answer to the question.
https://www.codexworld.com/export-html-to-word-doc-docx-using-javascript/

Django Graphos Chart Not Loaded On Table Update Using Ajax

I have been using django graphos and it works fine till i realize that the chart is not drawn when i update my table through ajax instead of a page refresh. Let me describe the issue further.
When my page is loaded for the first time, all the charts are loaded properly using {{chart.as_html}} . I am usng django by the way .
This charts are displayed in a table.
But when user selects different value from a dropdown and click reload, my code will only update the table through ajax instead of a whole page refresh. Unfortunately , when the table is updated, the chart with new data is not displayed. It just appears blank. I can see all the data from the developer tools but the chart just fail to appear.
I have checked through various topics but I am unable to get it working.
Part of my main html file
{% if objects %}
{% for obj in objects %}
<tr data-toggle="collapse" data-target="#{{obj.name}}" data-parent="#myGroup" class="accordion-toggle">
<!--tr>-->
<td style="border:0;"><img src='{{STATIC_URL}}/static/images/{{obj.name}}.png' class="infostockIcon"></td>
{% if obj.risk == "high" %}
{% if obj.dpr == "high" %}
<td class="tablerisk"><strong> * {{obj.name}} </strong></td>
{% else %}
<td class="tablerisk"><strong> {{obj.name}} </strong></td>
{% endif %}
<td class="tablerisk"> {{obj.stock_price}} </td>
<td class="tablerisk" style="color: black;"> {{obj.option_strategy}} </td>
<td class="tablerisk" style="color: black;"> {{obj.whiz_strategy}} </td>
<td class="tablerisk"> {{obj.strike_price}} </td>
<td class="tablerisk"> {{obj.expiry_date}} </td>
<td class="tablerisk"> {{obj.premium}} </td>
<td class="tablerisk"> {{obj.roi}} </td>
{% else %}
{% if obj.dpr == "high" %}
<td><strong> * {{obj.name}} </strong></td>
{% else %}
<td><strong> {{obj.name}} </strong></td>
{% endif %}
<td> {{obj.stock_price}} </td>
<td> {{obj.option_strategy}} </td>
<td> {{obj.whiz_strategy}} </td>
<td> {{obj.strike_price}} </td>
<td> {{obj.expiry_date}} </td>
<td> {{obj.premium}} </td>
<td> {{obj.roi}} </td>
{% endif %}
<td style="border:0;"><span class="caret black"></span></th></td>
</tr>
<tr>
<td style="border: 0;padding: 0 !important;"></td>
<td colspan="8" style="padding: 0 !important; border: none;">
<div class="accordion-body collapse" id="{{obj.name}}">
<ul id="tabs" class="nav nav-tabs" data-tabs="tabs">
<li data-toggle="tab" class="active">
Monthly Seasonality
</li>
<li data-toggle="tab">
Weekly Seasonality
</li>
<li data-toggle="tab">
Dividend
</li>
<li data-toggle="tab">
{{obj.name}} Info
</li>
</ul>
<div id="my-tab-content" class="tab-content">
<div class="tab-pane active" id="{{obj.name}}monthseason">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<h4>Monthly Seasonality<img src='{{STATIC_URL}}/static/info.png' class="infoIcon" style="float: none; right: 0px; margin-left: 5px" /></h4>
<div id="gchart_div">
{{ obj.monthly_chart.as_html}}
</div>
</div>
</div>
</div>
<div class="tab-pane" id="{{obj.name}}weekseason">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<h4>Weekly Seasonality<img src='{{STATIC_URL}}/static/info.png' class="infoIcon" style="float: none; right: 0px; margin-left: 5px"/></h4>
{{ obj.weekly_chart.as_html}}
</div>
</div>
</div>
<div class="tab-pane" id="{{obj.name}}dividend">
<!--div style="padding-left: 2%;" >-->
<div class="row">
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >TTM Dividend Yield:</label>
<label >{{obj.ttm_dividend_yield}}</label>
</div>
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >Ex-Dividend Date:</label>
<label >{{obj.ex_div}}</label>
</div>
</div>
<!--/div>-->
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<h4>Dividend Yield<img src='{{STATIC_URL}}/static/info.png' class="infoIcon" style="float: none; right: 0px; margin-left: 5px"/></h4>
{{obj.div_yearly_chart.as_html}}
</div>
</div>
</div>
<div class="tab-pane alignRight" id="{{obj.name}}data">
<div style="padding-left: 2%;" >
<div class="row">
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >Sector:</label>
<label >{{obj.sector}}</label>
</div>
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >Industry:</label>
<label >{{obj.industry}}</label>
</div>
</div>
<div class="row">
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >Earning Date:</label>
<label >{{obj.earnings_date}}</label>
</div>
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >Ex-Dividend Date:</label>
<label >{{obj.ex_div}}</label>
</div>
</div>
<div class="row">
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >52 Week Range:</label>
<label >{{obj.year_range}}</label>
</div>
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >5 Year Low:</label>
<label >{{obj.five_year_low}}</label>
</div>
</div>
<div class="row">
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >DPR:</label>
<label >{{obj.dpr_value}}</label>
</div>
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >Latest News:</label>
<a href={{obj.url}}>Seeking Alpha</a>
</div>
</div>
</div>
<br>
</div>
</div>
</div>
</td>
</tr>
My ajax call:
`var $myGroup = $('#myGroup');
$myGroup.on('show.bs.collapse','.collapse', function() {
$myGroup.find('.collapse.in').collapse('hide');
});
$('#tabs li a').click(function (e) {
$('#tabs li a.active').removeClass('active');
$(this).parent('li a').addClass('active');
});
$("#loadprofit").on("click", function(e)
{
//alert("asdas");
e.preventDefault();
var selectedOption = $("#strategy").val();
var selectedDate = $("#strategy2").val();
csrf_token = "{{ csrf_token }}";
$.ajax({
method: "POST",
url: window.location.href,
data: { selected_option: selectedOption,selected_date:selectedDate,csrfmiddlewaretoken: csrf_token },
})
.done(function( msg )
{
console.log(msg);
$("#sct tbody").html(msg);
});
});
</script>
{% endblock %}
`
This whole table gets updated when user clicks on a button. Then it calls views.py and table gets updated with the latest value. But {{ obj.monthly_chart.as_html}} is not loaded and it appears blank although i can see the whole chart drawing function and the data form the developer tool
Any help is greatly appreciated.

form data is not received

I am using Django and Bootstrap on frontend to write a single profile editing module.
Plain form from Django is ugly, so I did some custimizing on the form. Here is the HTML form:
<form actoin="{% url 'edit_profile' %}" method="post">
{% csrf_token %}
<div class="form-group row">
<label for="chineseName" class="col-sm-2 control-label">name</label>
<div class="col-sm-10">
<input name="chinese_name" class="form-control" id="chineseName" placeholder="name" value="{{form.chinese_name.value}}">
</div>
</div>
<div class="form-group row">
<label for="gender" class="col-sm-2 control-label">gender</label>
<div class="col-sm-10">
<label class="radio-inline">
{% if form.gender.value == "M" %}
<input type="radio" name="gender" id="gender1" value="M" checked> Male
{% else %}
<input type="radio" name="gender" id="gender2" value="M"> Male
{% endif %}
</label>
<label class="radio-inline">
{% if form.gender.value == "F" %}
<input type="radio" name="gender" id="gender1" value="F" checked> Female
{% else %}
<input type="radio" name="gender" id="gender2" value="F"> Female
{% endif %}
</label>
</div>
</div>
<div class="form-group row">
<label for="age" class="col-sm-2 control-label">age</label>
<div class="col-sm-10">
<input name="age" class="form-control" id="age" placeholder="年龄" value="{{form.age.value}}">
</div>
</div>
<div class="form-group row">
<label for="phone" class="col-sm-2 control-label">phone</label>
<div class="col-sm-10">
<input name="phone" class="form-control" id="phone" placeholder="phone" value="{{form.phone.value}}">
</div>
</div>
<div class="form-group row">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default col-xs-12" id="confirm" style="display:none;">confirm</button>
</div>
</div>
</form>
Somehow request.POST is not receiving data from this form. When I switch this long HTML snippet into {{form}}, everything is fine.
So view function is correct. Is there anything wrong with this template file, especially the form part?
You should add the css in the form class, for example if you are using ModelForm:
self.fields['phone'].widget.attrs['placeholder'] = self.fields['phone'].label
or if you are using Form :
phone = forms.CharField(widget=forms.TextInput(attrs={'placeholder' : 'phone'))
Nothing looks out of order at first look. One way to debug further would be to instantiate the form and print it. Then compare everything, especially the <form> tag and <input> tags.

How to create a popup with a form inside a table element in Django

I want to have a "sendemail" button for each element in the table, once the user clicks on this there should be a pop up with a form inside and a button. I tried using jquery for the popup but it is not working, can someone please tell me what I am doing wrong or suggest me any other way of creating this pop up. Currently I am using twitter bootstrap modal but want to replace that with a popup/popover
homepage.html
<table id="search-results" class="table table-hover">
</table>
ajax.js
$(function(){
$('#searchtest').click(function() {
$.ajax({
type: "POST",
url: "/searchtrips/",
data: {
'city' : $('#city').val(),
'location' : $('#location').val(),
'duration' : $('#duration').val(),
'search_text' : $('#searchtest').val(),
'csrfmiddlewaretoken' : $("input[name=csrfmiddlewaretoken]").val()
},
success: searchSuccess,
dataType: 'html'
});
});
});
function searchSuccess(data, textStatus, jqXHR)
{
$('#search-results').html(data);
}
search-results.html
{% for data in datas %}
<tr>
<td>{{ data.score}}</td>
<td>{{ data.distance}}</td>
<td>{{ data.time}}</td>
{%for element in data.place.elements%}
<td>
{{element.placeName}}
</td>
{% endfor %}
<td>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Share with your friends</h3>
</div>
<form action="{% url "send_mail"%}" class="form-horizontal" method="post">
<div class="control-group">
<label class="control-label" for="subject">Subject</label>
<div class="controls">
<input type="text" name="subject" value="Your friend has shared a traverse trip" id="subject" placeholder="subject">
</div>
</div>
<div class="control-group">
<label class="control-label" for="email">Email</label>
<div class="controls">
<input type="text" name="email" id="email" placeholder="Email">
</div>
</div>
<div class="control-group">
<label class="control-label" for="message">Message</label>
<div class="controls">
<input type="text" name="message" id ="message" placeholder="message" value ="Here we will have the link ">
</div>
</div>
<div class="modal-footer">
{% csrf_token %}
<input type="submit" value="email" class="btn btn-primary">
</div>
</form></div>
<i class="icon-envelope"></i>SendEmail
<a href="{% url "add_trip" city=data.score score=data.score distance=data.distance|floatformat:"0" time=data.time %}"
class ="btn btn-mini btn btn-warning">Add/delete</a>
</td>
</tr>
{% endfor %}*