我正在后端构建一个按钮,如下所示:
<?php
echo $this->myFormButton(
'add_component_restriction',
'Add',
[
'class' => 'btn btn-default add_component_restriction',
'type' => 'button'
]
);
?>
这将生成以下HTML:
<button name="add_component_restriction"
id="add_component_restriction"
type="button"
value="Add" class="btn btn-default add_component_restriction"
>Add</button>
元素可以呈现为视图,这意味着您可以查看它,但您无法对其进行操作,如果是,我应该能够删除它上面的所有操作。
我确实知道这只能在DOM级别上使用Javascript(也许我错了)可能使用.off()
或在元素上设置类似onclick="javascript: return false;"
的内容。
我不知道是否让它成为disabled
或readonly
。
Javascript / jQuery是唯一的方法吗?如果有其他解决方案,请告诉我
答案 0 :(得分:0)
添加disabled
属性。
<?php
echo $this->myFormButton(
'add_component_restriction',
'Add',
[
'class' => 'btn btn-default add_component_restriction',
'type' => 'button',
'disabled' => 'disabled'
]
);
?>