本文整理汇总了PHP中sfWidgetFormSchema::setParent方法的典型用法代码示例。如果您正苦于以下问题:PHP sfWidgetFormSchema::setParent方法的具体用法?PHP sfWidgetFormSchema::setParent怎么用?PHP sfWidgetFormSchema::setParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfWidgetFormSchema
的用法示例。
在下文中一共展示了sfWidgetFormSchema::setParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catch
try {
$w->setNameFormat('foo');
$t->fail('->setNameFormat() throws an InvalidArgumentException if the format does not contain %s');
} catch (InvalidArgumentException $e) {
$t->pass('->setNameFormat() throws an InvalidArgumentException if the format does not contain %s');
}
$w = new sfWidgetFormSchema(array('author' => new sfWidgetFormSchema(array('first_name' => new sfWidgetFormInputText(), 'company' => new sfWidgetFormSchema(array('name' => new sfWidgetFormInputText()))))));
$w->setNameFormat('article[%s]');
$t->is($w['author']->generateName('first_name'), 'article[author][first_name]', '->generateName() returns a HTML name attribute value for a given field name');
$t->is($w['author']['company']->generateName('name'), 'article[author][company][name]', '->generateName() returns a HTML name attribute value for a given field name');
// ->getParent() ->setParent()
$t->diag('->getParent() ->setParent()');
$author = new sfWidgetFormSchema(array('first_name' => new sfWidgetFormInputText()));
$company = new sfWidgetFormSchema(array('name' => new sfWidgetFormInputText()));
$t->is($company->getParent(), null, '->getParent() returns null if there is no parent widget schema');
$company->setParent($author);
$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');