Hi everyone,
I'm working with Adobe Experience Manager (AEM) and trying to set the disabled property to true on a specific field within a Content Fragment Model. My approach so far has been to directly modify the property via CRX/DE Lite. Here's what I did:
However, I've encountered an issue where this property is lost when I make changes to the Content Fragment Model, such as renaming a field or adding a new one. It seems the disabled property does not persist through these modifications.
Is there a recommended approach or best practice to ensure that the disabled property remains intact for a field, even after making changes to the Content Fragment Model? This field would be used for an ID, which authors should be able to view but not edit and it would be pre-filled by an event listener under the cores folder
Any advice or solutions would be greatly appreciated!
Thanks in advance!
Adding in the disabled property on CRX/DE and noticing that the id field is disabled and read only
After editing the content fragment model, the id field becomes editable and the disabled property is reverted on this field
Solved! Go to Solution.
There is no OOTB solution in AEM to persist a disabled state for a Content Fragment Model field.You need to customize the content fragment. You can overlay default dialog/component and set the property which you want to make it disabled and write custom model
@Model(adaptables = SlingHttpServletRequest.class)
public class CustomFragModel {
@inject
@default(values = "true")
private Boolean disableField;
//do your logic here
public Boolean isFieldDisabled() {
return disableField;
}
}
make property disable via js like this
$(document).ready(function() {
$('#field-id').attr('disabled', 'disabled');
});
Hope this helps!
There is no OOTB solution in AEM to persist a disabled state for a Content Fragment Model field.You need to customize the content fragment. You can overlay default dialog/component and set the property which you want to make it disabled and write custom model
@Model(adaptables = SlingHttpServletRequest.class)
public class CustomFragModel {
@inject
@default(values = "true")
private Boolean disableField;
//do your logic here
public Boolean isFieldDisabled() {
return disableField;
}
}
make property disable via js like this
$(document).ready(function() {
$('#field-id').attr('disabled', 'disabled');
});
Hope this helps!
Views
Likes
Replies