atk14 / confirmation-field
ConfirmationField 是 ATK14 应用程序的一个表单字段。它类似于 BooleanField(复选框),但 ConfirmationField 必须被勾选。
v1.0
2018-11-20 09:53 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-09-11 14:27:02 UTC
README
ConfirmationField 是 ATK14 应用程序的一个表单字段。它类似于 BooleanField(复选框),但 ConfirmationField 必须被勾选。
它是您应用程序中包含条款和条件的协议的正确字段。
安装
只需使用 Composer
cd path/to/your/atk14/project/
composer require atk14/confirmation-field
可选地,您可以从 vendor 到您的应用程序创建一个符号链接
ln -s ../../vendor/atk14/confirmation-field/src/confirmation_field.php app/fields/confirmation_field.php
用法
在表单中
<?php
// file: app/forms/orders/create_new_form.php
class CreateNewForm extends ApplicationForm {
function set_up(){
// fileds...
$this->add_field("confirmation", new ConfirmationField([
"label" => _("I agree with terms and conditions"),
]))->update_message("required","You have to agree with terms and conditions");
}
function clean(){
list($err,$data) = parent::clean();
// usually it's not required to have the confirmation in the cleaned data
unset($data["confirmation"]);
return [$err,$data];
}
}
许可证
ConfirmationField 是在 MIT 许可证条款下分发的免费软件https://open-source.org.cn/licenses/mit-license