dspym82000 2010-12-21 11:56 采纳率: 100%
浏览 23

需要用于Html-Select和Html-Input Group的Php Quickform Grouprule

i'm currently working on a big html form. I use Php Quickform to create and validate it. The form has a few Groups that consist of a Input-Textfield and a Select-field. The code for one of the groups

looks like this:

$autoren = array("0" => "", "1" => "Bob", "2" => "Harry", "3" => "Autor 3");
$arr[] = &HTML_QuickForm::createElement('text', 'autorT', 'AutorText', array('size' => 37, 'maxlength' => 50));
$arr[] = &HTML_QuickForm::createElement('select', 'autorO', 'AutorOptions', $autoren);
$form->addGroup($arr, 'Autoren', 'Autor:', '<br />');

I'm in desperate need of some kind of Rule/GroupRule that validates this group in the following way:

  1. If both fields are empty -> error.
  2. If one of the fields has a value in it, the other one must be empty, otherwise -> error.
  3. If both fields have values in them, they must match, otherwise -> error.

Can somebody explain to me how i can accomplish that? I already tried to write a custom rule, but somehow the code never called my validate method.

  • 写回答

1条回答 默认 最新

  • drxvjnx58751 2011-09-23 10:02
    关注

    If you're using HTML_QuickForm2, then chaining the rules with _and() and _or() makes possible what you want. With QF1, it's not possible (except using a callback rule on the form).

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度