Add/Replace EAN13 field on product combinations page - prestashop

i am trying to replace the "Impact on price (tax excl.)" field with EAN13 field at the product combinations tab because it is easier to scan barcodes and add quantities for all combinations at one page. I chose to replace this field and not add a new one because i will probably never use it.
So far i managed to show the field I want at the place of Impact on Price by modifying form_combination.html.twig file. It reads the EAN13 for products that already have it, but if I try to add or modify EAN13 of a product when I save it i get an error (just save error not a lot of info).
At first i just replaced "Impact on price" with "EAN13" field and when I got this error I thought it was because the impact on price field was missing so I put it where EAN13 was, but still got the save error message. If i delete the EAN13 of a product and try to save it, it works. It just doesn't when I try to add new or replace the existing one. What is wrong with the code?
Here is a pic of where i put the EAN13 field
Below is the original code
<tr class="combination loaded" id="attribute_{{ form.vars.value.id_product_attribute }}" data="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}">
<td width="1%"><input class="js-combination" type="checkbox" data-id="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}"></td>
<td class="img"><div class="fake-img"></div></td>
<td>{{ form.vars.value.name }}</td>
<td class="attribute-price">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">{{ default_currency }}</span>
</div>
<input type="text" class="attribute_priceTE form-control text-sm-right" value="{{ form.vars.value.attribute_price }}">
</div>
</td>
which i replaced with
<tr class="combination loaded" id="attribute_{{ form.vars.value.id_product_attribute }}" data="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}">
<td width="1%"><input class="js-combination" type="checkbox" data-id="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}"></td>
<td class="img"><div class="fake-img"></div></td>
<td>{{ form.vars.value.name }}</td>
<td class="attribute-price">
<div class="input-group">
<fieldset class="form-group">
<label class="form-control-label">
{{ form.attribute_ean13.vars.label }}
</label>
{{ form_errors(form.attribute_ean13) }}
{{ form_widget(form.attribute_ean13) }}
</fieldset>
</div>
</td>
Final code looks like this
{#**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license#prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* #author PrestaShop SA and Contributors <contact#prestashop.com>
* #copyright Since 2007 PrestaShop SA and Contributors
* #license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*#}
<tr class="combination loaded" id="attribute_{{ form.vars.value.id_product_attribute }}" data="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}">
<td width="1%"><input class="js-combination" type="checkbox" data-id="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}"></td>
<td class="img"><div class="fake-img"></div></td>
<td>{{ form.vars.value.name }}</td>
<td class="attribute-price">
<div class="input-group">
<fieldset class="form-group">
<label class="form-control-label">
{{ form.attribute_ean13.vars.label }}
</label>
{{ form_errors(form.attribute_ean13) }}
{{ form_widget(form.attribute_ean13) }}
</fieldset>
</div>
</td>
<td class="attribute-finalprice text-sm-right">
<span data-price="{{ form.vars.value.final_price }}" data-uniqid="{{ form.vars.value.id_product_attribute }}">{{ form.vars.value.final_price }}</span> {{ default_currency }}
</td>
{% if 'PS_STOCK_MANAGEMENT'|configuration %}
<td class="attribute-quantity">
<div>
<input type="text" value="{{ form.vars.value.attribute_quantity }}" class="form-control text-sm-right">
</div>
</td>
{% endif %}
<td class="attribute-actions">
<div class="btn-group btn-group-sm" role="group">
<i class="material-icons">mode_edit</i>
</div>
<div id="combination_form_{{ form.vars.value.id_product_attribute }}" data="{{ form.vars.value.id_product_attribute }}" class="combination-form hide row">
<div class="col-sm-12 nav">
{# "Prev." is short for "Previous" #}
<a class="btn-sensitive prev"><i class="material-icons">keyboard_arrow_left</i> {{ 'Prev. combination'|trans({}, 'Admin.Catalog.Feature') }}</a>
<a class="next btn-sensitive">{{ 'Next combination'|trans({}, 'Admin.Catalog.Feature') }} <i class="material-icons">keyboard_arrow_right</i></a>
</div>
<div class="panel col-md-12 p-2">
<div class="float-left">
<button type="button" class="back-to-product btn btn-outline-secondary btn-back"><i class="material-icons">arrow_back</i> {{ 'Back to product'|trans({}, 'Admin.Catalog.Feature') }}</button>
</div>
<h2 class="title pt-2">
{{ "Combination details"|trans({}, 'Admin.Catalog.Feature') }} -
{{ form.vars.value.name }}
</h2>
{{ form_widget(form.attribute_default) }}
<div class="row">
{% if 'PS_STOCK_MANAGEMENT'|configuration %}
<div class="col-md-2">
<fieldset class="form-group">
<label class="form-control-label">
{{ form.attribute_quantity.vars.label }}
</label>
{{ form_errors(form.attribute_quantity) }}
{{ form_widget(form.attribute_quantity) }}
</fieldset>
</div>
{% endif %}
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">{{ form.available_date_attribute.vars.label }}</label>
{{ form_errors(form.available_date_attribute) }}
{{ form_widget(form.available_date_attribute) }}
</fieldset>
</div>
<div class="col-md-2">
<fieldset class="form-group">
<label class="form-control-label">
{{ form.attribute_minimal_quantity.vars.label }}
<span class="help-box" data-toggle="popover"
data-content="{{ "The minimum quantity required to buy this product (set to 1 to disable this feature). E.g.: if set to 3, customers will be able to purchase the product only if they take at least 3 in quantity."|trans({}, 'Admin.Catalog.Help') }}" ></span>
</label>
{{ form_errors(form.attribute_minimal_quantity) }}
{{ form_widget(form.attribute_minimal_quantity) }}
</fieldset>
</div>
<div class="col-md-4">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_reference.vars.label }}</label>
{{ form_errors(form.attribute_reference) }}
{{ form_widget(form.attribute_reference) }}
</fieldset>
</div>
</div>
<h2 class="title">
{{ 'Stock'|trans({}, 'Admin.Catalog.Feature') }}
</h2>
<div class="row">
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_location.vars.label }}</label>
{{ form_errors(form.attribute_location) }}
{{ form_widget(form.attribute_location) }}
</fieldset>
</div>
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_low_stock_threshold.vars.label }}</label>
{{ form_errors(form.attribute_low_stock_threshold) }}
{{ form_widget(form.attribute_low_stock_threshold) }}
</fieldset>
</div>
<div class="col-md-9">
<fieldset class="form-group widget-checkbox-inline">
<label class="form-control-label"> </label>
<div class="widget-checkbox-inline">
{{ form_errors(form.attribute_low_stock_alert) }}
{{ form_widget(form.attribute_low_stock_alert) }}
<span class="help-box" data-toggle="popover" data-html="true" data-content="{{ "The email will be sent to all the users who have the right to run the stock page. To modify the permissions, go to [1]Advanced Parameters > Team[/1]"|trans({'[1]':'<a href="'~getAdminLink("AdminEmployees")~'">','[/1]':'</a>'}, 'Admin.Catalog.Help')|raw }}" ></span>
</div>
</fieldset>
</div>
</div>
<h2 class="title">
{{ "Price and impact"|trans({}, 'Admin.Catalog.Feature') }}
</h2>
<div class="row">
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_wholesale_price.vars.label }}</label>
{{ form_errors(form.attribute_wholesale_price) }}
{{ form_widget(form.attribute_wholesale_price) }}
</fieldset>
</div>
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">
{{ form.attribute_price.vars.label }}
<span class="help-box" data-toggle="popover"
data-content="{{ "Does this combination have a different price? Is it cheaper or more expensive than the default retail price?"|trans({}, 'Admin.Catalog.Help') }}" ></span>
</label>
{{ form_errors(form.attribute_price) }}
{{ form_widget(form.attribute_price) }}
</fieldset>
</div>
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_priceTI.vars.label }}</label>
{{ form_errors(form.attribute_priceTI) }}
{{ form_widget(form.attribute_priceTI) }}
</fieldset>
</div>
<div class="col-md-3">
<small class="form-control-label vcenter">{{ "Final retail price (tax excl.) will be"|trans({}, 'Admin.Catalog.Feature') }} <span class="final-price" data-price="{{ form.vars.value.final_price }}" data-uniqid="{{ form.vars.value.id_product_attribute }}">{{ form.vars.value.final_price }}</span> {{ default_currency }}</small>
</div>
</div>
<div class="row">
<div class="col-md-3 {% if 'PS_USE_ECOTAX'|configuration != 1 %}hide{% endif %}">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_ecotax.vars.label }}</label>
{{ form_errors(form.attribute_ecotax) }}
{{ form_widget(form.attribute_ecotax) }}
</fieldset>
</div>
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">
{{ form.attribute_unity.vars.label }}
<span class="help-box" data-toggle="popover"
data-content="{{ "Does this combination have a different price per unit?"|trans({}, 'Admin.Catalog.Feature') }}" ></span>
</label>
{{ form_errors(form.attribute_unity) }}
{{ form_widget(form.attribute_unity) }}
</fieldset>
</div>
<div class="col-md-3">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_weight.vars.label }}</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">{{ 'PS_WEIGHT_UNIT'|configuration }}</span>
</div>
{{ form_errors(form.attribute_weight) }}
{{ form_widget(form.attribute_weight) }}
</div>
</fieldset>
</div>
</div>
<h2 class="title">
{{ "Specific references"|trans({}, 'Admin.Catalog.Feature') }}
</h2>
<div class="row">
<div class="col-md-4">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_isbn.vars.label }}</label>
{{ form_errors(form.attribute_isbn) }}
{{ form_widget(form.attribute_isbn) }}
</fieldset>
</div>
<div class="col-md-4">
<fieldset class="form-group">
<label class="form-control-label">
{{ form.attribute_ean13.vars.label }}
<span class="help-box" data-toggle="popover"
data-content="{{ "This type of product code is specific to Europe and Japan, but is widely used internationally. It is a superset of the UPC code: all products marked with an EAN will be accepted in North America."|trans({}, 'Admin.Catalog.Help') }}" ></span>
</label>
{{ form_errors(form.attribute_ean13) }}
{{ form_widget(form.attribute_ean13) }}
</fieldset>
</div>
<div class="col-md-4">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_upc.vars.label }}</label>
{{ form_errors(form.attribute_upc) }}
{{ form_widget(form.attribute_upc) }}
</fieldset>
</div>
<div class="col-md-4">
<fieldset class="form-group">
<label class="form-control-label">{{ form.attribute_mpn.vars.label }}</label>
{{ form_errors(form.attribute_mpn) }}
{{ form_widget(form.attribute_mpn) }}
</fieldset>
</div>
</div>
<h2 class="title">
{{ "Images"|trans({}, 'Admin.Catalog.Feature') }}
</h2>
<div class="row">
<div class="col-md-12">
<fieldset class="form-group js-combination-images">
<label>
<small class="form-control-label">{{ form.id_image_attr.vars.label }}</small>
<small class="form-control-label number-of-images"></small>
</label>
{{ form_errors(form.id_image_attr) }}
{{ form_widget(form.id_image_attr) }}
</fieldset>
</div>
</div>
<div class="row">
<div class="col-md-12">
{{ renderhook('displayAdminProductsCombinationBottom', { 'id_product': form.vars.value.id_product, 'id_product_attribute': form.vars.value.id_product_attribute }) }}
</div>
</div>
{{ form_widget(form.id_product_attribute) }}
</div>
</div>
</td>
<td width="5%">
<i class="material-icons">delete</i>
</td>
<td>
{% set checked = form.vars.value.attribute_default == 1 ? 'checked' : '' %}
<input class="attribute-default" type="radio" {{ checked }} data-id="{{ form.vars.value.id_product_attribute }}">
</td>
</tr>

I finally managed to get it working, so I am posting the solution. I know it is not 100% correct and not upgrade friendly, but it does the job really good if you want to add barcode to combinations fast. For anyone wondering this is the working code i ended up with :
<tr class="combination loaded" id="attribute_{{ form.vars.value.id_product_attribute }}" data="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}">
<td width="1%"><input class="js-combination" type="checkbox" data-id="{{ form.vars.value.id_product_attribute }}" data-index="{{ form.vars.value.id_product_attribute }}"></td>
<td class="img"><div class="fake-img"></div></td>
<td>{{ form.vars.value.name }}</td>
<td>
<fieldset class="form-group">
{{ form_errors(form.attribute_ean13) }}
{{ form_widget(form.attribute_ean13) }}
</fieldset>
</td>
Code starts in line 25 of form_combination.html.twig
I also change the table header name at form_combinations.html.twig so that it says Barcode

Related

How to make boxes fields the same size

I'm using HTML and TWIG.
I have different boxes with different fields filled with data retrieved from a php call. The problem is I don't know how to make those fields (and consequently boxes) the same size.
The size of each field should be the tallest one of the group. So far I got this
As you can see, Contratto, JSer and Azienda are fine (usually always on a single line, so it shouldn't be a problem).
The problem is Note: as you can see, it goes well for single box, but having more ones just break the visualization. I'd like all fields to be the same size in their own group:
every Contratto the size of the biggest one;
every JSer the size of the biggest one;
every Azienda the size of the biggest one
and of course, the important one, every Note the size of the biggest one
Here's the code I'm using, with Bootstrap 3.3.7
{% if alerts|length > 0 %}
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> I TUOI AVVISI ({{ alerts|length }})</h3>
</div>
<div class="box-body">
{% for alert in alerts %}
<div class="col-lg-3 col-md-4 col-sm-6">
<div class="shadow-box">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f">Avviso</h3>
</div>
<div class="box-body">
<p><b>Contratto</b>: {{ alert.getJob().getContratto().getRiferimento() }}</p>
<p><b>JSer</b>: {{ alert.getJob().getJobStationer().getNome() }} {{ alert.getJob().getJobStationer().getCognome() }}</p>
<p><b>Azienda</b>: {{ alert.getJob().getAzienda().getNome() }}</p>
<p><b>Note</b>: {{ alert.getJob().getNote() }}</p>
</div>
{% if alert.getUtente() is not null %}
<div class="box-footer" style="text-align: left">
<p><b>Modificato da</b> {{ alert.getUtente().getNome() }} {{ alert.getUtente().getCognome() }} <b>il</b> {{ alert.getDataModifica()|date('d/m/Y') }}</p>
</div>
{% endif %}
<div class="box-footer">
<a href="{{ path('job_dettaglio', { 'id_job': alert.getJob().getId(), 'dettaglio': 1 }) }}"class="link-avviso">
Vai al dettaglio <i class="fa fa-angle-right" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
EDIT: this is the code version with columns and rows
{% if alerts|length > 0 %}
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> I TUOI AVVISI ({{ alerts|length }})</h3>
</div>
<div class="box-body">
{% for alert in alerts %}
<div class="col-lg-3 col-md-4 col-sm-6">
<div class="shadow-box">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f">Avviso</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-sm-12">
<b>Contratto</b>: {{ alert.getJob().getContratto().getRiferimento() }}
</div>
</div>
<div class="row">
<div class="col-sm-12">
<b>JSer</b>: {{ alert.getJob().getJobStationer().getNome() }} {{ alert.getJob().getJobStationer().getCognome() }}
</div>
</div>
<div class="row">
<div class="col-sm-12">
<b>Azienda</b>: {{ alert.getJob().getAzienda().getNome() }}
</div>
</div>
<div class="row">
<div class="col-sm-12">
<b>Note</b>: {{ alert.getJob().getNote() }}</p>
</div>
</div>
</div>
{% if alert.getUtente() is not null %}
<div class="box-footer" style="text-align: left">
<p><b>Modificato da</b> {{ alert.getUtente().getNome() }} {{ alert.getUtente().getCognome() }} <b>il</b> {{ alert.getDataModifica()|date('d/m/Y') }}</p>
</div>
{% endif %}
<div class="box-footer">
<a href="{{ path('job_dettaglio', { 'id_job': alert.getJob().getId(), 'dettaglio': 1 }) }}"class="link-avviso">
Vai al dettaglio <i class="fa fa-angle-right" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
Any suggestion?
EDIT ANSWER:
After few tries, I normalized the single row instead of single fields...single fields would not be the same height, but the row will, so this is actually fine for my final result. Here's the answer:
//CSS in head
.alertProperties {
padding-left:0px !important;
}
//Code
{% if alerts|length > 0 %}
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> I TUOI AVVISI ({{ alerts|length }})</h3>
</div>
<div class="box-body">
{% for alert in alerts %}
{% if loop.index % 5 == 0 or loop.first %}
<div class="row">
{% endif %}
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="box-header with-border"><h3 class="box-title" style="color: #ff000f">Avviso</h3></div>
<div class="box-body" style="border-left: 1px solid #00ACDF !important">
<div class="col-sm-12 alertProperties">
<b>Contratto</b>: {{ alert.getJob().getContratto().getRiferimento() }}
</div>
<div class="col-sm-12 alertProperties">
<b>JSer</b>: {{ alert.getJob().getJobStationer().getNome() }} {{ alert.getJob().getJobStationer().getCognome() }}
</div>
<div class="col-sm-12 alertProperties">
<b>Azienda</b>: {{ alert.getJob().getAzienda().getNome() }}
</div>
<div class="col-sm-12 alertProperties">
<b>Note</b>: {{ alert.getJob().getNote() }}</p>
</div>
{% if alert.getUtente() is not null %}
<div class="box-footer" style="text-align:left;">
<div class="col-sm-12 alertProperties">
<b>Modificato da</b> {{ alert.getUtente().getNome() }} {{ alert.getUtente().getCognome() }} <b>il</b> {{ alert.getDataModifica()|date('d/m/Y') }}
</div>
</div>
{% endif %}
<div class="box-footer">
<div class="col-sm-12">
<a href="{{ path('job_dettaglio', { 'id_job': alert.getJob().getId(), 'dettaglio': 1 }) }}" class="link-avviso">
Vai al dettaglio <i class="fa fa-angle-right" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
</div>
{% if (loop.index % 4 == 0 or loop.last) %}
</div>
{% endif %}
{% endfor %}
</div>
{# </div> #}
</div>
{% endif %}
You can truncate text of the note section by forcing text on the same line with the white-space:none
p{
width:400px;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
However if you wanna truncate it to more than one line you can read it more on chris coyier's article here

Shopify Ajax Update Cart

I want to be able to update my cart when I click on the increase button without having to click update button
Here is my script
<script>
let classlist = []
let val = document.querySelector('.qty-select')
let classes = document.getElementsByClassName('val')
for (var i=0; i<classes.length; i++) {
classlist.push(classes[i].innerText)
}
let lineclasses = classlist.join(", ")
val.onclick = function() {
jQuery.post('/cart/update.js', {updates: [lineclasses]});
console.log('dfdfdfd')
}
</script>
Here is my Liquid
{% for item in cart.items %}
<div class="product row">
<div class="col-lg-2 col-md-3 col-sm-4">
<img src="{{ item | img_url: 'medium' }}" />
</div>
<div class="col-lg-8 col-md-8 col-sm-7 product-info">
<div class="product-title">
{{ item.product.title }}
<span class="price right"><b>{{ item.price | money }}</b></span>
</div>
<div class="qty-select">
<input type="number" hidden="hidden" name="updates[]" id="updates_{{ item.key }}" class="qty"
value="{{ item.quantity }}" min="0" />
<span class="val">{{ item.quantity }}</span>
</div>
</div>
<div class="col-lg-2 col-md-1 col-sm-1 text-right remove">
<a aria-label="Remove {{ item.variant.title }}"
href="/cart/change?line={{ forloop.index }}&quantity=0"><i class="fas fa-times"></i></a>
</div>
</div>
{% endfor %}
I have tried this, but its not working

Adding code for Comment Boxes on Shopify Blog post in article.liquid

Im trying to add code back into shopify to allow for a comments box at the bottom of blog posts.
from my investigating, the code should exist in article.liquid, however it looks like the original developer deleted it.
I have tried entering code from Shopifys example https://shopify.github.io/liquid-code-examples/example/comment-list which produced no changes (Also I can't see there being an option to 'moderate' the comments, ideally we want to check them before they're posted on site.
Also tried a code from Github https://github.com/Shopify/Timber/blob/master/templates/article.liquid, which resulted in the below image. This code mentions 'moderate', but it didn't work.
github code error
Has anyone experience similar issue?
this is the current article.liquid code:
<div class="small-12 columns">
<article class="single-article">
<div class="article__title">
<h1 class="impact alpha">{{ blog.title }}</h1>
<h3 class="impact gamma">
<time pubdate datetime="{{ article.published_at | date: '%Y-%m-%d' }}">{{ article.published_at | date: '%b %d, %Y' }}</time> | {{ blog.title }}
</h3>
</div>
<div class="article__feature-image">
<img src="{{ article.image.src | img_url: '1024x1024' }}" alt="{{ article.image.alt }}">
</div>
<div class="article__content">
<div class="row">
<div class="small-12 medium-8 medium-offset-2 columns rte">
{{ article.content }}
</div>
</div>
</div>
<div class="article__paginate">
{% if blog.next_article or blog.previous_article %}
<div class="row">
<div class="small-12 medium-8 medium-offset-2 columns rte">
<p class="clearfix">
{% if blog.next_article %}
<span class="left impact epsilon">{{ '← Next Post' | link_to: blog.next_article }}</span>
{% endif %}
{% if blog.previous_article %}
<span class="right impact epsilon">{{ 'Previous Post →' | link_to: blog.previous_article }}</span>
{% endif %}
</p>
</div>
</div>
{% endif %}
</div>
<div class="article__author">
<div class="row">
<div class="small-12 medium-8 medium-offset-2 columns">
<div class="row">
<div class="author-image small-12 medium-3 columns">
<img src="http://www.gravatar.com/avatar/{{ article.user.email | md5 }}?s=100" />
</div>
<div class="author-details small-12 medium-9 columns">
<h4 class="impact epsilon">Written by {{ article.author }}</h4>
<p>{{ article.user.bio }}</p>
</div>
</div>
</div>
</div>
</div>
<div class="article__social clearfix">
<div class="row">
<div class="small-12 medium-8 small-centered columns">
<h4 class="epsilon impact">Share This</h4>
<br>
{% include 'snippets_share' %}
</div>
</div>
</div>
</article>
</div>

How to toggle nested checkboxes (options) on check parent checkbox in Vue Js

i have simple questions list. It has some options and those options has some nested suboptions.
So need to keep hidden all nested checkboxes until checks parent checkbox.
i tried to do it but could not get it work.
i have tried this so far:
For better understanding please have a look at this fiddle
<div id="app">
<h2>Questions:</h2>
<ul>
<li v-for="question in questions">
<div class="question">{{ question.question }}</div>
<div class="label__wrap" v-for="option in question.options">
<label>
<input type="checkbox" v-model="question.answer" :value="option.option">
<span>
{{ option.option }}
</span>
</label>
<div class="sub__label__wrap" v-for="opt in option.subOptions">
<label>
<input type="checkbox" v-model="option.subOptsAnswers" :value=" opt.option">
<span>
{{ opt.option }}
</span>
</label>
</div>
</div>
<br><br>
</li>
</ul>
</div>
Thanks.
Updated Fiddle : https://jsfiddle.net/rcam67b9/
check the answers array whether the selected answer exist
v-if="question.answer.indexOf(option.option) !== -1"
Final Code
<div id="app">
<h2>Questions:</h2>
<ul>
<li v-for="question in questions">
<div class="question">{{ question.question }}</div>
<div class="label__wrap" v-for="option in question.options">
<label>
<input type="checkbox" v-model="question.answer" :value="option.option">
<span>
{{ option.option }}
</span>
</label>
<div class="sub__label__wrap" v-for="opt in option.subOptions" v-if="question.answer.indexOf(option.option) !== -1">
<label>
<input type="checkbox" v-model="option.subOptsAnswers" :value=" opt.option">
<span>
{{ opt.option }}
</span>
</label>
</div>
</div>
<br><br>
</li>
</ul>
</div>

Bootstrap and horizontal radio buttons

I'm trying to display radio buttons horizontally using Bootstrap-CSS and Flask-WTForms. As far as I understand, I need to use the Bootstrap class class_="radio-inline" to accomplish that. I've tried it and all I get is this:
where radio buttons are, discouragingly, organized vertically.
Flask WTForm code:
from flask.ext.wtf import Form
import csv
import os
import buildHome as bh
from wtforms import TextField, RadioField, TextAreaField, SubmitField, validators, BooleanField
class ContactForm(Form):
firstName = TextField("First name", [validators.Required("Please enter your first name.")])
lastName = TextField("Last name", [validators.Required("Please enter your last name.")])
#name = TextField("Name", [validators.Required("Please enter your name.")])
email = TextField("Email", [validators.Required("Please enter your email address."), validators.Email("Please enter your email address.")])
node_1 = BooleanField("Joan Johnson (Buckridge Inc)")
direction_1 = RadioField('', choices=[('Choice1','Choice1'),('Choice2','Choice2'),('Choice3','Choice3')])
freq_1 = RadioField('', choices=[(1,'Daily'),(7,'Weekly'),(30,'Monthly'),(183,'Yearly'),(365,'More')])
submit = SubmitField("Send")
Html template for Flask to create the html code
{% extends "layout.html" %}
{% block content %}
<form action="{{ url_for('home') }}" method=post>
{{ form.hidden_tag() }}
<h3>Part I</h3>
<div class="well span6">
<div>
{{ form.firstName.label }} {{ form.firstName }}
</div>
<div>
{{ form.lastName.label }} {{ form.lastName }}
</div>
<div>
{{ form.email.label }} {{ form.email }}
</div>
</div>
<h3>Part II</h3>
<div <form class="form-horizontal" role="form">
<div class="well span6">
{{ form.node_1 (class_="checkbox style-2 pull-left") }} {{ form.node_1.label(class_="col-sm-3 control-label") }}
{{ form.direction_1.label }} {{ form.direction_1 (class_="radio-inline") }}
{{ form.freq_1.label }} {{ form.freq_1 (class_="radio-inline") }}
</div>
{{ form.submit }}{% endblock %}
Html script, produced by the Flask WTForm script above
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<!DOCTYPE html>
<html>
<head>
<title>TITLE</title>
<link rel="stylesheet" href="/static/css/bootstrap.css">
</head>
<body>
<header>
<div class="container">
<h1 class="logo">LOGO</h1>
<nav>
<ul class="menu">
<li>Home</li>
</ul>
</nav>
</div>
</header>
<div class="container">
<form action="/" method=post>
<div style="display:none;"><input id="csrf_token" name="csrf_token" type="hidden" value="1454454094##65db3f398f17785503e4bf13dfe76ad4879eb792"></div>
<h3>
Part I</h3>
<div class="well span6">
<div>
<label for="firstName">First name</label> <input id="firstName" name="firstName" type="text" value="">
</div>
<div>
<label for="lastName">Last name</label> <input id="lastName" name="lastName" type="text" value="">
</div>
<div>
<label for="email">Email</label> <input id="email" name="email" type="text" value="">
</div>
</div>
<h3>Part II</h3>
<div <form class="form-horizontal" role="form">
<div class="well span6">
<input class="checkbox style-2 pull-left" id="node_1" name="node_1" type="checkbox" value="y"> <label class="col-sm-3 control-label" for="node_1">Joan Johnson (Buckridge Inc)</label>
<label for="direction_1"></label> <ul class="radio-inline" id="direction_1"><li><input id="direction_1-0" name="direction_1" type="radio" value="Choice1"> <label for="direction_1-0">Choice1</label></li><li><input id="direction_1-1" name="direction_1" type="radio" value="Choice2"> <label for="direction_1-1">Choice2</label></li><li><input id="direction_1-2" name="direction_1" type="radio" value="Choice3"> <label for="direction_1-2">Choice3</label></li></ul>
<label for="freq_1"></label> <ul class="radio-inline" id="freq_1"><li><input id="freq_1-0" name="freq_1" type="radio" value="1"> <label for="freq_1-0">Daily</label></li><li><input id="freq_1-1" name="freq_1" type="radio" value="7"> <label for="freq_1-1">Weekly</label></li><li><input id="freq_1-2" name="freq_1" type="radio" value="30"> <label for="freq_1-2">Monthly</label></li><li><input id="freq_1-3" name="freq_1" type="radio" value="183"> <label for="freq_1-3">Yearly</label></li><li><input id="freq_1-4" name="freq_1" type="radio" value="365"> <label for="freq_1-4">More</label></li></ul>
</div>
<input id="submit" name="submit" type="submit" value="Send">
</div>
</body>
</html>
</body>
</html>
I'm probably missing something rather obvious, but can't get my finger on it. Also, it's my first time using Bootstrap or any CSS styling for that matter. So that might be it
In short, What am I doing wrong?
I found a solution!
All I needed to do was to iterate through my radio buttons field while building the html template, like so:
{% for subfield in form.freq_1 %}
<tr>
<td>{{ subfield }}</td>
<td>{{ subfield.label }}</td>
</tr>
{% endfor %}