Thank you very much for the pointer. I'm able to achieve what I was looking for. Below is the JS I ended up using.
Thanks again.
define([
'freeipa/phases',
'freeipa/user'],
function(phases, user_mod) {
// helper function
function get_item(array, attr, value) {
for (var i=0,l=array.length; i<l; i++) {
if (array[i][attr] === value) return array[i];
}
return null;
}
var fav_color_plugin = {};
fav_color_plugin.add_fav_color_number_pre_op = function() {
var facet = get_item(user_mod.entity_spec.facets, '$type', 'details');
var section = get_item(facet.sections, 'name', 'misc');
section.fields.splice(3, 0, {
name: 'favoritecolor',
label: 'Favorite Color',
read_only: true
});
var add_user_fields = user_mod.entity_spec.adder_dialog.sections[0].fields;
add_user_fields.splice(3, 0, {
name: 'favoritecolor',
required: true,
});
return true;
};
phases.on('customization', fav_color_plugin.add_fav_color_number_pre_op);
return fav_color_plugin;
});