Skip to content

Instantly share code, notes, and snippets.

@bartoszrychlicki
Created September 5, 2012 19:09
Show Gist options
  • Save bartoszrychlicki/3642765 to your computer and use it in GitHub Desktop.
Save bartoszrychlicki/3642765 to your computer and use it in GitHub Desktop.
{% block table_widget %}
<<<<<<< HEAD
{% if contentFieldValue != null %}
<script type="text/javascript">
$(document).ready(function(){
var data{{ contentFieldId }} = {{ tableData|raw }};
$("#grid-{{ contentFieldId }}").handsontable({
rows: data{{ contentFieldId }}.length > 0 ? data{{ contentFieldId }}.length : 1,
cols: (data{{ contentFieldId }}.length > 0 && data{{ contentFieldId }}[0].length > 0) ? data{{ contentFieldId }}[0].length : 1,
=======
{# display table editor only if the table is empty. NOTICE: it has to be an empty (meaning 0 rows x 0 cols) two-dimensional array#}
{# the condition != 'null' is temporary as csv import is not restored yet. the condition should be != '[[]]' #}
{% if tableData|raw != '[[]]' %}
<script type="text/javascript">
$(document).ready(function(){
var data{{ templateIndex }} = {{ tableData|raw }};
$("#grid-{{ templateIndex }}").handsontable({
rows: data{{ templateIndex }}.length > 0 ? data{{ templateIndex }}.length : 1,
cols: (data{{ templateIndex }}.length > 0 && data{{ templateIndex }}[0].length > 0) ? data{{ templateIndex }}[0].length : 1,
>>>>>>> 159f53e1e4629cc11b631b0a79daea77edef4579
minSpareCols: 0,
minSpareRows: 0,
contextMenu: true
});
<<<<<<< HEAD
$("#grid-{{ contentFieldId }}").handsontable("loadData", data{{ contentFieldId }});
});
</script>
<div id="grid-{{ contentFieldId }}" class="dataTable"></div>
<p>Remove? <input type="checkbox" name="remove_table" value="{{ contentFieldId }}"></p>
=======
$("#grid-{{ templateIndex }}").handsontable("loadData", data{{ templateIndex }});
});
</script>
<div id="grid-{{ templateIndex }}" class="dataTable"></div>
<p>Remove? <input type="checkbox" name="remove_table" value="{{ templateIndex }}"></p>
>>>>>>> 159f53e1e4629cc11b631b0a79daea77edef4579
{% else %}
{{ form_row(form.file) }}
{% endif %}
{% endblock %}
{% block image_widget %}
<<<<<<< HEAD
{% if contentFieldValue != null %}
<img src="{{ asset(contentFieldPath) }}" width="100" alt="Image">
<p>Remove? <input type="checkbox" name="remove_image" value="{{ contentFieldId }}"></p>
=======
{% if imageWebPath != null %}
<img src="{{ asset(imageWebPath) }}" width="100" alt="Image">
<p>Remove? <input type="checkbox" name="remove_image" value="{{ templateIndex }}"></p>
{% else %}
{{ form_row(form.file) }}
>>>>>>> 159f53e1e4629cc11b631b0a79daea77edef4579
{% endif %}
{% set type = type|default('file') %}
<input type="{{ type }}" {{ block('widget_attributes') }}>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment