Since I don’t like posting broken code, here are the pieces again and they seems to be working:
HTML:
{% if (laying_flocks.length == 0) { %}
<div class="col-xs-12">
<h2 class="text-muted text-center">There are no laying flocks in the database.</h2>
</div>
{% } %}
<form>
<table style="width:67%">
<tr><th>Flock</th><th>Yield</th></tr>
{% for (var i = 0; i < laying_flocks.length; i++) { %}
<tr><td>{%= laying_flocks[i].flock_identifier %}</td>
<td><input type="text" id="{%= laying_flocks[i].flock_identifier %}"></td></tr>
{% } %}
</table>
</form>
<style type="text/css">
.center-block span {
margin-top: 75%;
}
@media screen and (min-width: 320px) {
.center-block span {
margin-top: 45%;
}
}
</style>
And the JS:
frappe.provide("erpnext.utils");
frappe.ui.form.on('Egg Collection', {
refresh: function (frm) {
frappe.call({
method: "get_laying_flocks",
doc: cur_frm.doc,
callback: function (r) {
console.log(r.message);
laying_flocks = r.message;
var wrapper = $(cur_frm.fields_dict['htmlpopulate'].wrapper);
wrapper.html(frappe.render_template("eggcollection", laying_flocks))
}
})
}
})
Thanks @makarand_b, you were with me in spirit.