當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sfWidgetFormSchema::setIdFormat方法代碼示例

本文整理匯總了PHP中sfWidgetFormSchema::setIdFormat方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfWidgetFormSchema::setIdFormat方法的具體用法?PHP sfWidgetFormSchema::setIdFormat怎麽用?PHP sfWidgetFormSchema::setIdFormat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sfWidgetFormSchema的用法示例。


在下文中一共展示了sfWidgetFormSchema::setIdFormat方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: catch

EOF;
$t->is($child['name']->renderError(), fix_linebreaks($output), '->renderRow() renders errors as HTML when the widget has a parent');
try {
    $parent->renderError();
    $t->fail('->renderError() throws an LogicException if the form field has no parent');
} catch (LogicException $e) {
    $t->pass('->renderError() throws an LogicException if the form field has no parent');
}
// global errors
$authorErrorSchema = new sfValidatorErrorSchema(new sfValidatorString());
$authorErrorSchema->addError(new sfValidatorError(new sfValidatorString(), 'name error'), 'name');
$authorErrorSchema->addError(new sfValidatorError(new sfValidatorString(), 'non existent field error'), 'non_existent_field');
$authorErrorSchema->addError(new sfValidatorError(new sfValidatorString(), 'hidden field error'), 'id');
$articleErrorSchema = new sfValidatorErrorSchema(new sfValidatorString());
$articleErrorSchema->addError($titleError = new sfValidatorError(new sfValidatorString(), 'title error'), 'title');
$articleErrorSchema->addError($authorErrorSchema, 'author');
$parent = new sfFormFieldSchema($schema, null, 'article', array('title' => 'symfony', 'author' => array('name' => 'Fabien')), $articleErrorSchema);
$child = $parent['author'];
$output = <<<EOF
  <ul class="error_list">
    <li>non existent field error</li>
    <li>Id: hidden field error</li>
  </ul>

EOF;
$t->is($child->renderError(), fix_linebreaks($output), '->renderError() renders global errors as expected (global errors, hidden field errors, non existent field errors)');
// id format
$schema->setIdFormat('%s_id_format_test');
$parent = new sfFormFieldSchema($schema, null, 'article', array('title' => 'symfony', 'author' => array('name' => 'Fabien')), $articleErrorSchema);
$t->like($parent['author']->render(), '/_id_format_test/', '->render() uses the parent id format');
開發者ID:bigcalm,項目名稱:urlcatcher,代碼行數:30,代碼來源:sfFormFieldTest.php

示例2: array

$t->is($w->getGlobalErrors($errors), array('global error', 'error for w4', 'W2' => 'error for w2'), '->getGlobalErrors() returns an array of global errors, errors for hidden fields, and errors for non existent fields');
// ->render()
$t->diag('->render()');
$w = new sfWidgetFormSchema();
try {
    $w->render(null, 'string');
    $t->fail('->render() throws an InvalidArgumentException if the second argument is not an array');
} catch (InvalidArgumentException $e) {
    $t->pass('->render() throws an InvalidArgumentException if the second argument is not an array');
}
$w['first_name'] = $w1;
$w['last_name'] = $w2;
$w['id'] = new sfWidgetFormInputHidden();
$w->setAttribute('style', 'padding: 5px');
$w->setNameFormat('article[%s]');
$w->setIdFormat('id_%s');
$expected = <<<EOF
<tr><td colspan="2">
  <ul class="error_list">
    <li>Global error message</li>
    <li>Id: Required</li>
  </ul>
</td></tr>
<tr>
  <th><label style="padding: 5px" for="id_article_first_name">First name</label></th>
  <td>  <ul class="error_list">
    <li>Too short</li>
  </ul>
<input class="foo" type="text" name="article[first_name]" value="Fabien" id="id_article_first_name" /></td>
</tr>
<tr>
開發者ID:xmasclaux,項目名稱:OpenGenepi,代碼行數:31,代碼來源:sfWidgetFormSchemaTest.php


注:本文中的sfWidgetFormSchema::setIdFormat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。