I'm in the process of developing a GUI extension to hide a schema field when the component loads. For now I am testing the feasibility in Firebug using the following code to get the actual field:
function getControlForFieldName(name){
var fieldBuilder = $display.getView().properties.controls.fieldBuilder;
var fieldsContainer = fieldBuilder.properties.input;
var fieldsNode = fieldsContainer.getElement();
var fieldContainer = $dom.getFirstElementChild(fieldsNode);
while (fieldContainer) {
var labelNode = $dom.getFirstElementChild(fieldContainer);
var fieldNode = $dom.getNextElementSibling(labelNode);
var control = fieldNode.control;
if (control.getFieldName() == name) {
return control;
}
fieldContainer = $dom.getNextElementSibling(fieldContainer);
}
}
From here I am able to call it and I get the field successfully:
var fieldControl = getControlForFieldName('some_xml_field_name');
I am now stuck trying to find a method that the fieldControl
object can use to hide the field. I've tried fieldControl.disable()
and fieldControl.dispose()
with no luck. I also tried experimenting with the jQuery .hide()
method but I can't seem to find a valid selector through this API.
I was thinking something along this form:
$j(fieldControl.getId()).hide()
I think I'm close to solving the problem but I am missing one or two final pieces. Has anyone done this yet?
Also, in case anyone is wondering why I decided on the GUI ext. as opposed to a simpler method (such as instructions on the field description or educating users):
- I already have hundreds of components created using those schema fields and
- I'm migrating from 5.3 and this extension already exists - I need to continue supporting a similar functionality in 2011 SP1 - disabling the fields would work also.