cancel
Showing results for 
Search instead for 
Did you mean: 

How to recognize if a user views or edits a node in a repository form filter?

jego
Star Contributor
Star Contributor

I want to edit some values of form fields when a user views an existing node (view mode). In edit mode I don´t want to modify these values... My

Currently, I have configured a form filter for changing some form field values. 

<bean id="formFilter"
class="xxx"
parent="baseFormFilter">

<property name="filterRegistry" ref="nodeFilterRegistry" />
</bean>‍‍‍‍‍‍‍‍‍‍‍

I have implemented the method, but this method runs in view and edit mode

public void afterGenerate(final ItemType item, final List<String> fields, final List<String> forcedFields,
final Form form, final Map<String, Object> context) {

How can I differentiate these two modes?

I know that it is possible to define fields for certain modes (example: <show id="cm:creator" for-mode="view" />) in the share-config.xml, but maybe this information (if the user views or edit a node) is only available in Share, not in the repository?

Thanks

Jens

1 ACCEPTED ANSWER

afaust
Legendary Innovator
Legendary Innovator

You cannot - the Repository-tier filters are oblivious to the mode the form is to be displayed in. That information is not even passed to the Repository-tier. What I typically do when I need some specially constructed values for read-only views is to generate transient fields in the form and configure those fields (instead of the actual property) in the view form in Share.

View answer in original post

3 REPLIES 3

afaust
Legendary Innovator
Legendary Innovator

You cannot - the Repository-tier filters are oblivious to the mode the form is to be displayed in. That information is not even passed to the Repository-tier. What I typically do when I need some specially constructed values for read-only views is to generate transient fields in the form and configure those fields (instead of the actual property) in the view form in Share.

douglascrp
World-Class Innovator
World-Class Innovator

‌ Interesting.

Do you have any sample code to share?

I never thought about that.

afaust
Legendary Innovator
Legendary Innovator

Not really. But it is effectively not different to what a transient field processor would do - create the field definition and add it to the form, and additionally add the data for it to the form as well.