本文整理汇总了PHP中DataForm::AddValidator方法的典型用法代码示例。如果您正苦于以下问题:PHP DataForm::AddValidator方法的具体用法?PHP DataForm::AddValidator怎么用?PHP DataForm::AddValidator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataForm
的用法示例。
在下文中一共展示了DataForm::AddValidator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDataFormValidation
function testDataFormValidation()
{
$xmlstr = <<<XML
<fields>
\t<field iseditable="1" description="Phone" type="phone" registry_format="+[2].[4-16]" name="Phone" required="1" />
\t<field iseditable="1" type="select" name="asia_identform" description="Form of Identity" required="0">
\t\t<values>
\t\t\t<value name="Certificate of Incorp" value="certificate"/>
\t\t\t<value name="Charter" value="legislation"/>
\t\t\t<value name="Societies Registry" value="societyRegistry"/>
\t\t\t<value name="Political Party Registry" value="politicalPartyRegistry"/>
\t\t\t<value name="Passport/Citizenship ID" value="passport"/>
\t\t\t<value name="Other" value="other"/>
\t\t</values>
\t</field>
\t<!-- required if asia_identform=other -->
\t<field iseditable="1" type="text" name="asia_otheridentform" description="Other Identification Form" required="0" note="Required when form of identity is 'Other'"/>
</fields>\t\t
XML;
$manifest = simplexml_load_string($xmlstr);
$dform = new DataForm();
$dform->AppendFromXML($manifest);
$dform->AddXMLValidator($manifest);
$dform->AddValidator(create_function('$name, $value, $data', 'if (!$data["asia_identform"] && !$value) return "identform or otheridentform must be set";'), "asia_otheridentform");
$err = $dform->Validate(array());
var_dump($err);
return;
$manifest = simplexml_load_string('<fields><field iseditable="0" description="Full name" type="text" name="name" required="1" minlength="3" maxlength="255" /></fields>');
$err = $dform->ValidateOverManifest($manifest, array("name" => "ma"));
var_dump($err);
$dform->Bind(array("name" => "vv"));
$err = $dform->ValidateOverManifest($manifest, array("name" => "ma"));
var_dump($err);
}