piranha-cms - How to set a CheckBoxField initially checked when adding a new block in manager in Piranha CMS
问题描述
I'm creating a custom block with some ChekBoxFields in Piranha CMS. When a user adds this block in a page in the manager, I want to set some of the Checkbox as already checked.
I am new to C# and Piranha and I am not able to understand how to do it, nor I could find a clue in the docs or searching.
Here is what I tryed first:
[Field(Title = "Show controls")]
public CheckBoxField EnableControls { get; set; } = new CheckBoxField { Value = true};
And then:
[Field(Title = "Show controls")]
public CheckBoxField EnableControls { get; set; } = true;
Then I tryed to set the value in the constructor:
public MyBlock()
{
EnableControls = true;
}
In all cases the checkbox starts unchecked.
Can anyone help me or point me to some resource about it?
Thank you.
解决方案
推荐阅读
- angular - 角度 CLI 将构建警告更改为错误
- python - 如何将客户分配给 Django 中的用户?
- modal-dialog - 带有 gatsby-image 的全尺寸图像的模态 - 限制高度和宽度
- python - 如何获取下载按钮的 url 并在 Python 中读取 CSV 文件?
- python - Python 从多个单独的 Python 进程写入文件,我必须锁定文件吗?
- java - 我是否必须在访问公共工作表的 Java 客户端应用程序中使用默认的 google API 身份验证?
- microsoft-graph-api - 收到 callRecord 通知后从 SharePoint 获取媒体文件
- r - 所有成绩单的线性回归
- javascript - 在 JavaScript 中将嵌套数组拆分为多个数组
- python-3.x - 将图像写入 PDF 文件