本文整理汇总了PHP中sfWidgetFormSchema::setDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP sfWidgetFormSchema::setDefault方法的具体用法?PHP sfWidgetFormSchema::setDefault怎么用?PHP sfWidgetFormSchema::setDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfWidgetFormSchema
的用法示例。
在下文中一共展示了sfWidgetFormSchema::setDefault方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sfWidgetFormSchema
$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'));
$t->is($w->getDefaults(), array('w1' => 'foo', 'w2' => null), '->getDefaults() returns the default values');
$t->is($w->getDefault('w1'), 'foo', '->getDefault() returns the default value for a given field');
$w->setDefault('w2', 'foo');
$t->is($w->getDefaults(), array('w1' => 'foo', 'w2' => 'foo'), '->setDefault() sets a default value for a given field');
// ->needsMultipartForm()
$t->diag('->needsMultipartForm()');
$w = new sfWidgetFormSchema(array('w1' => $w1));
$t->is($w->needsMultipartForm(), false, '->needsMultipartForm() returns false if the form schema does not have a widget that needs a multipart form');
$w['w2'] = new sfWidgetFormInputFile();
$t->is($w->needsMultipartForm(), true, '->needsMultipartForm() returns true if the form schema does not have a widget that needs a multipart form');
// ->renderField()
$t->diag('->renderField()');
$w = new sfWidgetFormSchema(array('first_name' => $w1));
$t->is($w->renderField('first_name', 'Fabien'), '<input class="foo1" type="text" name="first_name" value="Fabien" id="first_name" />', '->renderField() renders a field to HTML');
$ww = clone $w1;
$ww->setAttribute('id', 'foo');
$ww->setAttribute('style', 'color: blue');
$w = new sfWidgetFormSchema(array('first_name' => $ww));