本文整理汇总了PHP中sfWidgetFormSchema::generateName方法的典型用法代码示例。如果您正苦于以下问题:PHP sfWidgetFormSchema::generateName方法的具体用法?PHP sfWidgetFormSchema::generateName怎么用?PHP sfWidgetFormSchema::generateName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfWidgetFormSchema
的用法示例。
在下文中一共展示了sfWidgetFormSchema::generateName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catch
$w->setFormFormatterName('list');
$t->is(get_class($w->getFormFormatter()), 'sfWidgetFormSchemaFormatterList', '->setFormFormatterName() set the names of the formatter to use when rendering');
$w->setFormFormatterName('nonexistant');
try {
$w->getFormFormatter();
$t->fail('->setFormFormatterName() throws a InvalidArgumentException when the form format name is not associated with a formatter');
} catch (InvalidArgumentException $e) {
$t->pass('->setFormFormatterName() throws a InvalidArgumentException when the form format name is not associated with a formatter');
}
$formatterNames = array_keys($w->getFormFormatters());
sort($formatterNames);
$t->is($formatterNames, array('custom', 'list', 'table'), '->getFormFormatters() returns an array of all formatter for this widget schema');
// ->setNameFormat() ->getNameFormat() ->generateName()
$t->diag('->setNameFormat() ->getNameFormat() ->generateName()');
$w = new sfWidgetFormSchema();
$t->is($w->generateName('foo'), 'foo', '->generateName() returns a HTML name attribute value for a given field name');
$w->setNameFormat('article[%s]');
$t->is($w->generateName('foo'), 'article[foo]', '->setNameFormat() changes the name format');
$t->is($w->getNameFormat(), 'article[%s]', '->getNameFormat() returns the name format');
$w->setNameFormat(false);
$t->is($w->generateName('foo'), 'foo', '->generateName() returns the name unchanged if the format is false');
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');