I have a modal popup that appears whenever the editor tries to save the component with some values ββ(a date field in the past in this case).
In this pop-up window, I will show the editor a few options (very similar to the Open Common Element dialog box by default) and the OK / Cancel button combination. In the "Cancel" field, I fire the "cancel" event, and the editor returns to the editing screen, everything is fine here. In "OK" I want to change the value of the field in accordance with the selected editor, and then save.
I tried using the FieldBuilder approach and the Boris sample mentioned in this other section , but I cannot get into the field from my pop-up dialog box.
Any suggestions on how I can go and change the xml of an element (maybe also a page) from a modal popup?
EDIT: Code Used in getControlForFieldName
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); } }
CHANGE No. 2
After Frank advised, and some help from Jaime and Frank offline, I got him to work as follows:
- The popup menu is called from the command line (Save and close in my case)
- The command.js command indicates an event handler that is called on "submit" (OK was pressed)
$evt.addEventHandler(p.dialogPopup, "submit", this.getDelegate(this._onPopupSubmit));
In my popup, I pass the selected item (this is the keyword identifier) ββto the event handler:
this.fireEvent("submit", { id: select.options[select.selectedIndex].value });
and now in the _onPopupSubmit(e)
event handler I just read e.data.id, load this keyword, get properties like ID and Title, and update the item metadata using item.setMetadata ("new metadata with updated values") .
Plain:)