I want to select option 1 and load a form with inputs
HTML:
<select id="orden" class="form-control" name="orden">
<option disabled selected>Selecciona una opción</option>
<option value="1">{{ results.1.op_ser_codigo }}{{ results.1.op_num_codigo }} / ({{ results.1.data_ini }} - {{ results.1.data_fim }})</option>
<option value="2">{{ results.2.op_ser_codigo }}{{ results.2.op_num_codigo }} / ({{ results.2.data_ini }} - {{ results.2.data_fim }})</option>
<option value="3">{{ results.3.op_ser_codigo }}{{ results.3.op_num_codigo }} / ({{ results.3.data_ini }} - {{ results.3.data_fim }})</option>
<option value="4">{{ results.4.op_ser_codigo }}{{ results.4.op_num_codigo }} / ({{ results.4.data_ini }} - {{ results.4.data_fim }})</option>
<option value="5">{{ results.5.op_ser_codigo }}{{ results.5.op_num_codigo }} / ({{ results.5.data_ini }} - {{ results.5.data_fim }})</option>
<option value="6">{{ results.6.op_ser_codigo }}{{ results.6.op_num_codigo }} / ({{ results.6.data_ini }} - {{ results.6.data_fim }})</option>
</select>
I want to fill this: (If on select option i select 1 on this inputs fill value 1)
<b><p class="black">OP: </b>{{ results.1.op_ser_codigo }}{{results.1.op_num_codigo}} </p>
<b><p class="black">Fecha Inicio: </b>{{ results.1.data_ini }} </p>
<b><p class="black">Fecha Final: </b> {{ results.1.data_fim }} </p>
You can handle it on client side (with jq, javascript) or on the server side. I definitely advice to handle it on the server side - as business logic should be there. Although in this case - as I understand - the trigger will come after the form is loaded and once the select options is selected.
I would go with an ajax solution.
place an onchange event to the select:
eg:
onchange="ChooseOption(this.value)"
add javascript to handle ajax request(I use jquery):
function ChooseOption(option_id){
$.ajax({
type: "POST",
url: "/applicatioin/option_selection/",
data: {
'option_id' : option_id,
'csrfmiddlewaretoken' :
$("input[name=csrfmiddlewaretoken]").val()
},
success: chooseoptionDetailSuccess,
dataType: 'html'
});
}
In the success you call chooseoptionDetailSuccess function. Which should pass the data to the relevant html field - with innerHtml.
Note: you may also use GET request type.
In you django view you have to render a html template which holds the html part (with the variables) which will be changed.
Sorry for the format. Seems like the code sample is not working.
how do i update this, in column_left controller?
if ($catalog) {
$data['menus'][] = array(
'id' => 'menu-catalog',
'icon' => 'fa-tags',
'name' => $this->language->get('text_catalog'),
'href' => '',
'children' => $catalog
);
}
you can't because it is hardcoded for evey menu,
and even you manage to get this done , some other extension you installed still need that update fix
in column left controller
'icon' => 'fa-tags', chaange it to 'icon' => 'glyphicon glyphicon-user'
nothing to change in view , it will work ,
You should customize the html in "admin/view/template/common/column_left.twig"
For example .. replace this code :
{% if menu.href %}<i class="fa {{ menu.icon }} fw"></i> {{ menu.name }}
by:
{% if menu.href %}{% if menu.img %}<img src="{{ menu.img }}"> {{ menu.name }}{% else %}<i class="fa {{ menu.icon }} fw"></i> {{ menu.name }}{% endif %}
and adding the image path in menu array item in column_left controller :
'img' => 'view/image/file.png'
I have a flask page that is for editing blog posts. It has the following vue:
<form method="POST" action="{{ url_for('edit',itemid=item.id) }}" id="text-input">
{{ form.csrf_token }}
<div style="margin-left:30px;margin-top:20px;">
Title: {{ form.title }}
</div>
<br/>
<div id="editor">
Content: {{ form.content( **{':value':'input','#input': 'update'}) }}
<div v-html="compiledMarkdown"></div>
</div>
<br/>
Category: {{ form.category|safe }}
<br/>
<input type="submit" value="Save">
</form>
<script>
new Vue({
el: '#editor',
data: {
input: "starting data"
},
computed: {
compiledMarkdown: function () {
return marked(this.input, { sanitize: true })
}
},
methods: {
update: _.debounce(function (e) {
this.input = e.target.value
}, 300)
}
});
</script>
What I would like to do is have a starting value for input based on something sent in by flask. Basically I would change input: "starting data" to input: {{ form.content.data }}. However, when I do this, it stops updating the input when I change the text in the box. I think I am kind of hardcoding the data to be whatever what in form.content.data as opposed to a string.
How can I pass this in so that it starts with the form.content.data value yet is still changeable?
The reason it didn't work was because {{ form.content.data }} appears in the template as raw text.
Thus it was trying to use something like: the brown fox jumped over the lazy dog
and this doesn't compile to a javascript object. Adding quotes around the {{ form.content.data }} like '{{ form.content.data }}' fixed it.
i'm little bit new to this.
I had read the documentation of Laravel 4 and some of the Mailgun, I had tested some mail and worked but just in route like this:
Route::get('send_test_email', function(){
Mail::send('emails.registro', array('key' => 'value'), function($message)
{
$message->subject('Bienvenido a la gran experiencia');
$message->from(env('CONTACT_MAIL'), env('CONTACT_NAME'));
$message->to('luis02lopez#hotmail.com');
});
});
I went to myapp/send_test_email in the browser and get an email.
But now I want to send an email at registration, I created the route:
Route::get('mail', ['uses' => 'MailController#send', 'as' => 'send']);
The controller:
<?php
class MailController extends \BaseController {
public function index()
{
return View::make('signup');
}
public function send() {
Mail::send('emails.registro', $data, function($message) use
{
$message->subject('Bienvenido a la gran experiencia');
$message->from(env('CONTACT_MAIL'), env('CONTACT_NAME'));
$message->to($user->email, $user->firstname);
});
}
And added a form to the signup form like this:
{{ Form::open(['route' => 'send', 'method' => 'get']) }}
<div class="form-group">
{{ Form::label('username', 'Usuario', ['class' => 'sr-only']) }}
{{ Form::text('username', null, ['placeholder' => 'Usuario', 'required', 'minlength' => 6, 'class' => 'form-control', ]) }}
#foreach($errors->get('username', '<span class=error>:message</span>') as $message)
{{$message}}
#endforeach
</div>
<div class="form-group">
{{ Form::label('password', 'Contraseña', ['class' => 'sr-only']) }}
{{ Form::password('password', ['placeholder' => 'Contraseña', 'required', 'minlength' => 8, 'class' => 'form-control']) }}
#foreach($errors->get('password', '<span class=error>:message</span>') as $message)
{{$message}}
#endforeach
</div>
<div class="form-group">
{{ Form::label('password_confirm', 'Confirmar Contraseña', ['class' => 'sr-only']) }}
{{ Form::password('password_confirmation', ['placeholder' => 'Confirmar Contraseña', 'required', 'minlength' => 8, 'class' => 'form-control']) }}
#foreach($errors->get('password_confirmation', '<span class=error>:message</span>') as $message)
{{$message}}
#endforeach
</div>
<div class="form-group">
{{ Form::label('email', 'Email', ['class' => 'sr-only']) }}
{{ Form::email('email', null, ['placeholder' => 'Email', 'required', 'class' => 'form-control']) }}
#foreach($errors->get('email', '<span class=error>:message</span>') as $message)
{{$message}}
#endforeach
</div>
<div class="form-group">
{{ Form::label('firstname', 'Nombres', ['class' => 'sr-only']) }}
{{ Form::text('firstname', null, ['placeholder' => 'Nombres', 'required', 'class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('lastname', 'Apellidos', ['class' => 'sr-only']) }}
{{ Form::text('lastname', null, ['placeholder' => 'Apellidos', 'required', 'class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::submit('Registrar', ['class' => 'btn btn-lg btn-block btn-kinbu'])}}
</div>
{{ Form::close() }}
And I got a Parse error: syntax error, unexpected 'Mail' (T_STRING) in the controller, why?
Here I have errors:
public function send() {
Mail::send('emails.registro', $data, function($message) use
{
$message->subject('Bienvenido a la gran experiencia');
$message->from(env('CONTACT_MAIL'), env('CONTACT_NAME'));
$message->to($user->email, $user->firstname);
});
}
I'm using the $user var, but I'm not passing it with the closure "user" so I have to do:
public function send() {
Mail::send('emails.registro', array('key' => 'value'), function($message) use ($user)
{
$message->subject('Bienvenido a la gran experiencia');
$message->from(env('CONTACT_MAIL'), env('CONTACT_NAME'));
$message->to($user->email, $user->firstname);
});
}
I am using the following code:
<select onchange="javascript:location.href = this.value;">
<option value="" selected>-- Show Genre --</option>
#foreach ($genres as $genre)
<option value="{{ URL::route('tracks.order', array('order' => 'name', 'by' => 'asc', 'genre' => $genre->name )) }}">{{ $genre->name }}</option>
#endforeach
</select>
The $genres is populated using the following code in my controller:
$genres = Genres::lists('name', 'id');
I was wondering if I could use a code like below instead of the foreach? I think I should be able to, but I have no clue on how to change the code to work with my code above.
{{ Form::select('genre', array('default' => '-- Select Genre --') + $genres, '') }}
You may try something like this:
$genres = ['default' => '-- Select Genre --'] + Genres::lists('name', 'id');
In the view:
{{ Form::select('genre', $genres, Form::old('genre')) }}