我有一个create.html表单,其中包含从我的spring roo 2.0域模型生成的字段:
<div class="form-group has-error has-feedback" data-z="790e58b4" id="consultation-prediction-field" data-th-classappend="${#fields.hasErrors('prediction')}? 'has-error has-feedback'" data-th-class="form-group">
<label for="prediction" class="col-md-3 control-label" data-th-text="#{label_consultation_prediction}">prediction</label>
<div class="col-md-3">
<input id="prediction" name="prediction" data-th-value="*{{prediction}}" type="text" class="form-control inputmask" placeholder="prediction" data-th-placeholder="#{label_consultation_prediction}" data-toggle="tooltip" aria-describedby="predictionStatus" data-inputmask-alias="numeric" data-inputmask-digits="2" />
<span data-th-classappend="${#fields.hasErrors('prediction')}? 'glyphicon glyphicon-remove form-control-feedback'" class="glyphicon glyphicon-remove form-control-feedback" data-th-if="${#fields.hasErrors('prediction')}" aria-hidden="true"></span>
<span id="prediction-error" class="help-block" data-th-if="${#fields.hasErrors('prediction')}" data-th-errors="*{prediction}">Error message.</span>
</div>
</div>
我想在用户界面中禁用该字段。我试图将disabled
属性添加到input
字段定义中:
<div class="form-group has-error has-feedback" data-z="790e58b4" id="consultation-prediction-field" data-th-classappend="${#fields.hasErrors('prediction')}? 'has-error has-feedback'" data-th-class="form-group">
<label for="prediction" class="col-md-3 control-label" data-th-text="#{label_consultation_prediction}">prediction</label>
<div class="col-md-3">
<input id="prediction" name="prediction" disabled data-th-value="*{{prediction}}" type="text" class="form-control inputmask" placeholder="prediction" data-th-placeholder="#{label_consultation_prediction}" data-toggle="tooltip" aria-describedby="predictionStatus" data-inputmask-alias="numeric" data-inputmask-digits="2" />
<span data-th-classappend="${#fields.hasErrors('prediction')}? 'glyphicon glyphicon-remove form-control-feedback'" class="glyphicon glyphicon-remove form-control-feedback" data-th-if="${#fields.hasErrors('prediction')}" aria-hidden="true"></span>
<span id="prediction-error" class="help-block" data-th-if="${#fields.hasErrors('prediction')}" data-th-errors="*{prediction}">Error message.</span>
</div>
</div>
这暂时有效,但是spring roo在重新生成表单时会删除此disabled
属性。
如何永久设置此属性?
看来我只需要设置属性:
data-z="user-managed"
在该字段的form-group
中。