labels_display_on_top - subform ?
Posted: Sat May 23, 2020 1:27 pm
This snipet does not affect subform.
Code snippets for nuBuilder4 https://github.com/smalos/nuBuilder4-Code-Librarykev1n wrote:I don't understand what your question is, what you are referring to.
Code: Select all
jQuery.fn.labelOnTop = function(offsetTop = -18, offsetLeft = 0){
return this.each(function() {
$('#' + 'label_' + this.id).css({
'top': parseInt($(this).css("top")) + offsetTop,
'left': parseInt($(this).css("left")) + offsetLeft,
'text-align': 'left'
})
});
};
Code: Select all
$('[id^=subfromObjID]).labelOnTop();
Code: Select all
$('[id^=subfromObjID][id$=firstname]').labelOnTop();
It seems we again do not understand each other, communicating via google-translate.kev1n wrote:Here is a new convenient function:
[img] [/img]kev1n wrote: So please show us the code you're using and also a picture of the subform properties so we can see the object ID.
Code: Select all
function custFieldLabelsOnTop(f, e) {
for (var i = 0; i < f.length; i++) {
if (jQuery.inArray(f[i], e) == -1) {
var t = $('#' + f[i]).cssNumber("top");
var l = $('#' + f[i]).cssNumber("left");
$('#' + 'label_' + f[i]).css({
'top': t - 18,
'left': l - 15
})
}
}
}
jQuery.fn.cssNumber = function(prop){
var v = parseInt(this.css(prop),10);
return isNaN(v) ? 0 : v;
};
Code: Select all
if (nuFormType() == 'edit') {
var f = nuSubformObject("").fields; // include all fields of your main form.
custFieldLabelsOnTop(f, []);
}
Code: Select all
if (nuFormType() == 'edit') {
var f = nuSubformObject("").fields; // include all fields of your main form.
custFieldLabelsOnTop($.merge(f,['sub_vupusk']), []);
}
Thanks! its ok.kev1n wrote:I see where the problem is. nuSubformObject("").fields doesn't contain the subform object.
Just add the subform object separately to the fields array:
Code: Select all
if (nuFormType() == 'edit') { var f = nuSubformObject("").fields; // include all fields of your main form. custFieldLabelsOnTop($.merge(f,['sub_vupusk']), []); }