当前位置: 首页>>代码示例>>PHP>>正文


PHP sfForm::renderUsing方法代码示例

本文整理汇总了PHP中sfForm::renderUsing方法的典型用法代码示例。如果您正苦于以下问题:PHP sfForm::renderUsing方法的具体用法?PHP sfForm::renderUsing怎么用?PHP sfForm::renderUsing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sfForm的用法示例。


在下文中一共展示了sfForm::renderUsing方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

$t->is($f->render(array('first_name' => array('class' => 'foo'))), fix_linebreaks($output), '->render() renders the form as HTML');
$t->is((string) $f['id'], '<input type="hidden" name="id" value="1" id="id" />', '->offsetGet() returns a sfFormField');
$t->is((string) $f['first_name'], '<input type="text" name="first_name" value="Fabien" id="first_name" />', '->offsetGet() returns a sfFormField');
$t->is((string) $f['last_name'], '<input type="text" name="last_name" value="Potencier" id="last_name" />', '->offsetGet() returns a sfFormField');
// renderUsing()
$t->diag('->renderUsing()');
$f = new sfForm();
$f->setWidgets(array('name' => new sfWidgetFormInputText()));
$output = <<<EOF
<li>
  <label for="name">Name</label>
  <input type="text" name="name" id="name" />
</li>

EOF;
$t->is($f->renderUsing('list'), fix_linebreaks($output), 'renderUsing() renders the widget schema using the given form formatter');
$t->is($f->getWidgetSchema()->getFormFormatterName(), 'table', 'renderUsing() does not persist form formatter name for the current form instance');
$w = $f->getWidgetSchema();
$w->addFormFormatter('custom', new sfWidgetFormSchemaFormatterList($w));
$t->is($f->renderUsing('custom'), fix_linebreaks($output), 'renderUsing() renders a custom form formatter');
try {
    $f->renderUsing('nonexistant');
    $t->fail('renderUsing() throws an exception if formatter name does not exist');
} catch (InvalidArgumentException $e) {
    $t->pass('renderUsing() throws an exception if formatter name does not exist');
}
// renderHiddenFields()
$t->diag('->renderHiddenFields()');
$f = new sfForm();
$f->setWidgets(array('id' => new sfWidgetFormInputHidden(), 'name' => new sfWidgetFormInputText(), 'is_admin' => new sfWidgetFormInputHidden()));
$output = '<input type="hidden" name="id" id="id" /><input type="hidden" name="is_admin" id="is_admin" />';
开发者ID:Tony-M,项目名称:GrannySymfony,代码行数:31,代码来源:sfFormTest.php

示例2: array

$t->is($f->render(array('first_name' => array('class' => 'foo'))), $output, '->render() renders the form as HTML');
$t->is((string) $f['id'], '<input type="hidden" name="id" value="1" id="id" />', '->offsetGet() returns a sfFormField');
$t->is((string) $f['first_name'], '<input type="text" name="first_name" value="Fabien" id="first_name" />', '->offsetGet() returns a sfFormField');
$t->is((string) $f['last_name'], '<input type="text" name="last_name" value="Potencier" id="last_name" />', '->offsetGet() returns a sfFormField');
// renderUsing()
$t->diag('->renderUsing()');
$f = new sfForm();
$f->setWidgets(array('name' => new sfWidgetFormInput()));
$output = <<<EOF
<li>
  <label for="name">Name</label>
  <input type="text" name="name" id="name" />
</li>

EOF;
$t->is($f->renderUsing('list'), $output, 'renderUsing() renders the widget schema using the given form formatter');
$t->is($f->getWidgetSchema()->getFormFormatterName(), 'table', 'renderUsing() does not persist form formatter name for the current form instance');
// renderHiddenFields()
$t->diag('->renderHiddenFields()');
$f = new sfForm();
$f->setWidgets(array('id' => new sfWidgetFormInputHidden(), 'name' => new sfWidgetFormInput(), 'is_admin' => new sfWidgetFormInputHidden()));
$output = '<input type="hidden" name="id" id="id" /><input type="hidden" name="is_admin" id="is_admin" />';
$t->is($f->renderHiddenFields(), $output, 'renderHiddenFields() renders all hidden fields, no visible fields');
$t->is(count($f->getFormFieldSchema()), 3, 'renderHiddenFields() does not modify the form fields');
// ->embedForm()
$t->diag('->embedForm()');
$author = new FormTest(array('first_name' => 'Fabien'));
$author->setWidgetSchema($author_widget_schema = new sfWidgetFormSchema(array('first_name' => new sfWidgetFormInput())));
$author->setValidatorSchema($author_validator_schema = new sfValidatorSchema(array('first_name' => new sfValidatorString(array('min_length' => 2)))));
$company = new FormTest();
$company->setWidgetSchema($company_widget_schema = new sfWidgetFormSchema(array('name' => new sfWidgetFormInput())));
开发者ID:WIZARDISHUNGRY,项目名称:symfony,代码行数:31,代码来源:sfFormTest.php


注:本文中的sfForm::renderUsing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。