Magnolia CMS:春暖花开段落重复数据验证
我在 Spring Flower 中定义了一个段落,其中包含编辑、文件、选择和日期控件。现在我只想允许该页面中的每个日期输入一个数据,即日期字段应该是唯一的。如何根据 DailogValidator 中的日期字段进行重复数据验证?
谢谢, 鲁帕里
I have a paragraph defined in spring blossom which consists of edit,file, select and date controls. Now I want to allow only one data entry for each date in that page, i.e. date field should be unique. How can I do duplicate data validation based on date field in DailogValidator?
Thanks,
Rupali
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在验证器中,您可以访问内容并可以迭代它以查找具有相同日期的段落。
您可以从 MgnlContext.getAggregationState() 或通过将 DialogCreationContext 添加为验证器方法的参数来获取内容。
当迭代页面的内容时,您应该查看具有相同段落的 ContentNode 类型的节点。分配给节点的段落在节点元数据中设置为“模板”。
这个code 的作用基本相同,但您可能希望将其从按类搜索更改为搜索名称。
希望有帮助!
In the validator you have access to the content and can iterate through it looking for a paragraph having the same date.
You can get the content either from MgnlContext.getAggregationState() or by adding DialogCreationContext as an argument to your validator method.
When iterating the content of the page you should be looking at nodes of type ContentNode having the same paragraph. The paragraph assigned to the node is set in the nodes MetaData as 'template'.
This code does basically the same thing but you might want to change it from searching by class to searching for name instead.
Hope that helps!