如何解决在 Drupal 7 中禁用 webform 中的 required 选项
我的功能:
function _custom_get_ublox_communication_checkbox_form_element() {
return array(
'#type' => 'checkboxes','#title' => t('Communications'),'#options' => array(
1 => t('I consent to retaining my personal data for the purposes of receiving personalized marketing materials,offers,invitations to webinars and other similar events. To learn more,read our <a )),),'#required' => TRUE,);
}
此复选框是强制性的,因为有选项 '#required' => TRUE,但在删除必需选项后,它甚至没有从字段中删除 required(*) 复选框。
解决方法
如果你只想使用一个复选框元素,你应该使用'checkbox'类型而不是'checkboxes'
https://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/7.x#checkbox
因此,如果您不需要它,请使用 FALSE 值
function _custom_get_ublox_communication_checkbox_form_element() {
return array(
'#type' => 'checkbox','#title' => t('I consent to retaining my personal data for the purposes of receiving personalized marketing materials,offers,invitations to webinars and other similar events. To learn more,read our <a'),'#required' => FALSE,);
}
测试前清除所有缓存
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。