form Display元素

对于display元素,在代码
MacroFormRenderer.renderDisplayField()方法

可以看到代码

StringWriter sr = new StringWriter();
        sr.append("<@renderDisplayField ");
        sr.append("type=\"");
        sr.append(type);
        sr.append("\" imageLocation=\"");
        sr.append(imageLocation);
        sr.append("\" idName=\"");
        sr.append(idName);
        sr.append("\" description=\"");
        sr.append(FreeMarkerWorker.encodeDoubleQuotes(description));
        sr.append("\" class=\"");
        sr.append(modelFormField.getWidgetStyle());
        sr.append("\" alert=\"");
        sr.append(modelFormField.shouldBeRed(context)? "true": "false");

其中alert如果是true,那么会自动给输出的span html元素添加class = alert的内容。就是红色字体。其中modelFormField.shouldBeRed(context)这个方法根据字段是fromDate名字还是thruDate名字,然后再判断时间是比fromDate小,就是红色,或者时间比thruDate大就是红色。

你可能感兴趣的:(display)