本文整理汇总了PHP中Am_Form_Admin::addRule方法的典型用法代码示例。如果您正苦于以下问题:PHP Am_Form_Admin::addRule方法的具体用法?PHP Am_Form_Admin::addRule怎么用?PHP Am_Form_Admin::addRule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Am_Form_Admin
的用法示例。
在下文中一共展示了Am_Form_Admin::addRule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createForm
/**
* Add elements to config form
* no need to add "time" controls
*/
protected function createForm()
{
$form = new Am_Form_Admin('form-' . $this->getId());
$form->addDataSource(new HTML_QuickForm2_DataSource_Array($this->getFormDefaults()));
$form->setAction(REL_ROOT_URL . '/admin-reports/run/report_id/' . $this->getId());
if ($this->getPointFieldType() == self::POINT_DATE) {
$start = $form->addElement('Date', 'start')->setLabel(___('Start'));
$start->addRule('required');
$stop = $form->addElement('Date', 'stop')->setLabel(___('End'));
$stop->addRule('required');
$form->addRule('callback', 'Start Date cannot be later than the End Date', array($this, 'checkStopDate'));
$quant = $form->addElement('Select', 'quant')->setLabel(___('Quantity'));
$quant->addRule('required');
$quant->loadOptions($this->getQuantityOptions());
}
$this->_initConfigForm($form);
$form->addSubmit('save', array('value' => ___('Run Report')));
return $form;
}
示例2: createImportForm
function createImportForm(&$defaults)
{
$form = new Am_Form_Admin();
/** count imported */
$imported_products = $this->getDi()->db->selectCell("SELECT COUNT(id) FROM ?_data WHERE `table`='product' AND `key`='wom:id'");
$wopCfg = $this->db_wordpress->selectCell("SELECT option_value FROM ?_options WHERE option_name = ?", 'ws_plugin__optimizemember_options');
$wopCfg = unserialize($wopCfg);
if (is_array($wopCfg)) {
$amProducts = array('' => '-- Please Select --') + $this->getDi()->productTable->getOptions();
$womProducts = array();
for ($i = 0; $i <= 10; $i++) {
$womProducts['level' . ($i ? $i : '')] = $wopCfg['level' . $i . '_label'];
}
if ($imported_products) {
$cb = $form->addStatic()->setContent("Linked");
} else {
$cb = $form->addRadio('import', array('value' => 'product'));
foreach ($womProducts as $key => $value) {
$form->addSelect("pr_link[" . $key . "]")->setLabel($value)->loadOptions($amProducts);
}
$form->addRule('callback2', '-error-', array($this, 'validateForm'));
}
$cb->setLabel('Link Products');
}
if (!is_array($wopCfg) || $imported_products) {
$imported_users = $this->getDi()->db->selectCell("SELECT COUNT(id) FROM ?_data WHERE `table`='user' AND `key`='wom:id'");
$total = $this->db_wordpress->selectCell("SELECT COUNT(*) FROM ?_users");
if ($imported_users >= $total) {
$cb = $form->addStatic()->setContent("Imported ({$imported_users})");
} else {
$cb = $form->addGroup();
if ($imported_users) {
$cb->addStatic()->setContent("partially imported ({$imported_users} of {$total} total)<br /><br />");
}
$cb->addRadio('import', array('value' => 'user'));
$cb->addStatic()->setContent('<br /><br /># of users (keep empty to import all) ');
$cb->addInteger('user[count]');
$cb->addStatic()->setContent('<br />Keep the same user IDs');
$keep_id_chkbox = $cb->addCheckbox('user[keep_user_id]');
if ($this->getDi()->db->selectCell("SELECT COUNT(*) FROM ?_user")) {
$keep_id_chkbox->setAttribute('disabled');
$cb->addStatic()->setContent('User database have records already. Please use Clean Up if you want to keep the same user IDs');
}
}
$cb->setLabel('Import User and Payment Records');
}
$form->addSaveButton('Run');
$defaults = array();
return $form;
}