本文整理汇总了PHP中sfWidgetFormSchema::setHelp方法的典型用法代码示例。如果您正苦于以下问题:PHP sfWidgetFormSchema::setHelp方法的具体用法?PHP sfWidgetFormSchema::setHelp怎么用?PHP sfWidgetFormSchema::setHelp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfWidgetFormSchema
的用法示例。
在下文中一共展示了sfWidgetFormSchema::setHelp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sfWidgetFormSchema
$t->is($company->getParent(), $author, '->getParent() returns the parent widget schema');
// ->setLabels() ->setLabel() ->getLabels() ->getLabel() ->generateLabelName()
$t->diag('->setLabels() ->setLabel() ->getLabels() ->getLabel() ->generateLabelName()');
$w = new sfWidgetFormSchema(array('first_name' => new sfWidgetFormInputText()));
$w->setLabel('first_name', 'A first name');
$t->is($w->getLabels(), array('first_name' => 'A first name'), '->getLabels() returns all current labels');
$w->setLabels(array('first_name' => 'The first name'));
$t->is($w->getFormFormatter()->generateLabelName('first_name'), 'The first name', '->setLabels() changes all current labels');
$w->setLabel('first_name', 'A first name');
$t->is($w->getFormFormatter()->generateLabelName('first_name'), 'A first name', '->setLabel() sets a label value');
// ->setHelps() ->getHelps() ->setHelp() ->getHelp()
$t->diag('->setHelps() ->getHelps() ->setHelp() ->getHelp()');
$w = new sfWidgetFormSchema();
$w->setHelps(array('first_name', 'Please, provide your first name'));
$t->is($w->getHelps(), array('first_name', 'Please, provide your first name'), '->setHelps() changes all help messages');
$w->setHelp('last_name', 'Please, provide your last name');
$t->is($w->getHelp('last_name'), 'Please, provide your last name', '->setHelp() changes one help message');
// ->getLabel() ->setLabel() ->getLabels() ->setLabels()
$t->diag('->getLabel() ->setLabel() ->getLabels() ->setLabels()');
$w = new sfWidgetFormSchema(array('w1' => $w1, 'w2' => $w2));
$w->setLabels(array('w1' => 'foo'));
$t->is($w->getLabels(), array('w1' => 'foo', 'w2' => null), '->getLabels() returns the labels');
$t->is($w->getLabel('w1'), 'foo', '->getLabel() returns the label for a given field');
$w->setLabel('w2', 'foo');
$t->is($w->getLabels(), array('w1' => 'foo', 'w2' => 'foo'), '->setLabel() sets a label for a given field');
$w->setLabel('foo');
$t->is($w->getLabel(), 'foo', '->setLabel() can also set the label for the widget schema');
// ->getDefault() ->setDefault() ->getDefaults() ->setDefaults()
$t->diag('->getDefault() ->setDefault() ->getDefaults() ->setDefaults()');
$w = new sfWidgetFormSchema(array('w1' => $w1, 'w2' => $w2));
$w->setDefaults(array('w1' => 'foo'));
示例2: createBuildWidgetValidator
/**
* @param array $parameters
* @return array
*/
private function createBuildWidgetValidator($parameters)
{
$extraParametersWidgets = array();
$extraParametersValidators = array();
foreach ($parameters as $name => $parameter) {
if (is_array($parameter['choices'])) {
$extraParametersWidgets[$name] = new sfWidgetFormChoice(array('choices' => $this->combine($parameter['choices']), 'default' => $parameter['default']), array('label' => strlen($parameter['description']) > 0 ? $parameter['description'] : $name));
$extraParametersValidators[$name] = new sfValidatorChoice(array('choices' => $parameter['choices']));
} else {
$extraParametersWidgets[$name] = new sfWidgetFormInput(array('default' => $parameter['default']), array('label' => strlen($parameter['description']) > 0 ? $parameter['description'] : $name));
$extraParametersValidators[$name] = new sfValidatorString(array('required' => false));
}
}
$widget = new sfWidgetFormSchema($extraParametersWidgets, array('label' => 'Parameters'));
$widget->setDefaultFormFormatterName('jobParameter');
foreach ($parameters as $name => $parameter) {
if ($parameter['description']) {
$widget->setHelp($name, $parameter['description']);
}
}
$validator = new sfValidatorSchema($extraParametersValidators);
return array($widget, $validator);
}