本文整理匯總了PHP中DataForm::Bind方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataForm::Bind方法的具體用法?PHP DataForm::Bind怎麽用?PHP DataForm::Bind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DataForm
的用法示例。
在下文中一共展示了DataForm::Bind方法的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);
}