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


PHP sfWidgetFormSchema::setNameFormat方法代码示例

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


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

示例1: setup

 /**
  * Setup the form.  To overload, you should use ->configure()
  */
 public function setup()
 {
     $widgetSchema = new sfWidgetFormSchema(array('query' => new sfWidgetFormInput()), array(), array(), array(), array());
     $widgetSchema->addFormFormatter('sfLuceneSimple', new sfLuceneWidgetFormatterSimple($widgetSchema));
     $widgetSchema->setFormFormatterName('sfLuceneSimple');
     $widgetSchema->setNameFormat('form[%s]');
     $validatorSchema = new sfValidatorSchema(array('query' => new sfValidatorString(array('required' => true)), 'page' => new sfValidatorInteger(array('required' => false, 'empty_value' => 1))), array(), array());
     if ($this->hasCategories()) {
         $widgetSchema['category'] = new sfWidgetFormSelect(array('choices' => $this->getCategories(), 'multiple' => false));
         $validatorSchema['category'] = new sfValidatorChoice(array('required' => false, 'choices' => $this->getCategories()));
     }
     $this->setWidgetSchema($widgetSchema);
     $this->setValidatorSchema($validatorSchema);
 }
开发者ID:rande,项目名称:sfSolrPlugin,代码行数:17,代码来源:sfLuceneSimpleFormBase.class.php

示例2: setup

 /**
  * Setup the form.  To overload, you should use ->configure()
  */
 public function setup()
 {
     $widgetSchema = new sfWidgetFormSchema(array('keywords' => new sfWidgetFormInput(), 'musthave' => new sfWidgetFormInput(), 'mustnothave' => new sfWidgetFormInput(), 'hasphrase' => new sfWidgetFormInput()), array(), array(), array('keywords' => 'May contain keywords', 'musthave' => 'Must contain keywords', 'mustnothave' => 'Must exclude keywords', 'hasphrase' => 'Contains exact phrase'), array());
     $widgetSchema->addFormFormatter('sfLuceneAdvanced', new sfLuceneWidgetFormatterAdvanced($widgetSchema));
     $widgetSchema->setFormFormatterName('sfLuceneAdvanced');
     $widgetSchema->setNameFormat('form[%s]');
     $validatorSchema = new sfValidatorSchema(array('keywords' => new sfValidatorString(array('required' => false)), 'musthave' => new sfValidatorString(array('required' => false)), 'mustnothave' => new sfValidatorString(array('required' => false)), 'hasphrase' => new sfValidatorString(array('required' => false))), array(), array());
     if ($this->hasCategories()) {
         $widgetSchema['category'] = new sfWidgetFormSelect(array('choices' => $this->getCategories(), 'multiple' => false));
         $widgetSchema->setLabel('category', 'Must be in category');
         $validatorSchema['category'] = new sfValidatorChoice(array('required' => false, 'choices' => $this->getCategories()));
     }
     $this->setWidgetSchema($widgetSchema);
     $this->setValidatorSchema($validatorSchema);
 }
开发者ID:palcoprincipal,项目名称:sfLucenePlugin,代码行数:18,代码来源:sfLuceneAdvancedFormBase.class.php

示例3: dirname

<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(31);
// widgets
$authorSchema = new sfWidgetFormSchema(array('id' => new sfWidgetFormInputHidden(), 'name' => $nameWidget = new sfWidgetFormInputText()));
$authorSchema->setNameFormat('article[author][%s]');
$schema = new sfWidgetFormSchema(array('title' => $titleWidget = new sfWidgetFormInputText(), 'author' => $authorSchema));
$schema->setNameFormat('article[%s]');
// errors
$authorErrorSchema = new sfValidatorErrorSchema(new sfValidatorString());
$authorErrorSchema->addError(new sfValidatorError(new sfValidatorString(), 'name error'), 'name');
$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);
$f = $parent['title'];
$child = $parent['author'];
// ->getValue() ->getWidget() ->getParent() ->getError() ->hasError()
$t->diag('->getValue() ->getName() ->getWidget() ->getParent() ->getError() ->hasError()');
$t->ok($f->getWidget() == $titleWidget, '->getWidget() returns the form field widget');
$t->is($f->getName(), 'title', '->getName() returns the form field name');
$t->is($f->getValue(), 'symfony', '->getValue() returns the form field value');
$t->is($f->getParent(), $parent, '->getParent() returns the form field parent');
开发者ID:bigcalm,项目名称:urlcatcher,代码行数:31,代码来源:sfFormFieldTest.php

示例4: array

$errors = array('global error', 'w1' => 'error for w1', 'w2' => 'error for w2', 'w4' => array('w1' => 'error for w4/w1', 'w2' => 'error for w4/w2', 'w3' => 'error for w4/w3'), 'w4' => 'error for w4');
$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>
开发者ID:xmasclaux,项目名称:OpenGenepi,代码行数:31,代码来源:sfWidgetFormSchemaTest.php

示例5: dirname

<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(31);
// widgets
$authorSchema = new sfWidgetFormSchema(array('id' => new sfWidgetFormInputHidden(), 'name' => $nameWidget = new sfWidgetFormInputText()));
$authorSchema->setNameFormat('article[author][%s]');
$schema = new sfWidgetFormSchema(array('title' => $titleWidget = new sfWidgetFormInputText(), 'author' => $authorSchema));
$schema->setNameFormat('article[%s]');
$titleWidget->setParent($schema);
// errors
$authorErrorSchema = new sfValidatorErrorSchema(new sfValidatorString());
$authorErrorSchema->addError(new sfValidatorError(new sfValidatorString(), 'name error'), 'name');
$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);
$f = $parent['title'];
$child = $parent['author'];
// ->getValue() ->getWidget() ->getParent() ->getError() ->hasError()
$t->diag('->getValue() ->getName() ->getWidget() ->getParent() ->getError() ->hasError()');
$t->ok($f->getWidget() == $titleWidget, '->getWidget() returns the form field widget');
$t->is($f->getName(), 'title', '->getName() returns the form field name');
$t->is($f->getValue(), 'symfony', '->getValue() returns the form field value');
开发者ID:hunde,项目名称:bsc,代码行数:31,代码来源:sfFormFieldTest.php


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