I've a boolean field in the model just similar to the below one. And I want to create a view using embedded javascript.
**settings.js**
module.exports = {
attributes: {
myField:{
type:'boolean',
defaultsTo:'false'
}
}
};
这是我正在使用的代码
<form action="/settings/create" method="POST" id="sign-up-form" class="form-inline">
<div class="form-group">
<label for="field1">my field label</label>
<input type="checkbox" class="form-control" id="field1" name="myField">
</div>
<input type="submit" class="btn btn-primary" value="Create"/>
<input type="hidden" name="_csrf" value="<%= _csrf %>" />
</form>
所以我面临的问题是
答案 0 :(得分:0)
<div class="form-group">
<label for="confirmationBox">Field Label</label>
<% if(object.fieldName==true || object.fieldName=="true"){ %>
<input type="checkbox" id="confirmationBox" name="confirmationBox" checked>
<% } else { %>
<input type="checkbox" id="confirmationBox" name="confirmationBox">
<% } %>
</div>