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


PHP sfWidgetFormSchema::addFormFormatter方法代码示例

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


在下文中一共展示了sfWidgetFormSchema::addFormFormatter方法的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: sfWidgetFormChoice

$t->diag('->render()');
$w = new sfWidgetFormChoice(array('choices' => array('foo' => 'bar')));
$t->like($w->render('foo'), '/<select name="foo" id="foo">/', '->render() renders a select tag by default');
$w->setIdFormat('barID_%s');
$t->like($w->render('foo'), '/<select name="foo" id="barID_foo">/', '->render() uses the id format specified');
$w->setIdFormat('%s');
$w->setOption('multiple', true);
$t->like($w->render('foo'), '/<select name="foo\\[\\]" multiple="multiple" id="foo">/', '->render() adds a multiple attribute for multiple selects');
$w->setOption('expanded', true);
$t->like($w->render('foo'), '/<ul class="checkbox_list">/', '->render() uses a checkbox list when expanded and multiple are true');
$w->setOption('multiple', false);
$t->like($w->render('foo'), '/<ul class="radio_list">/', '->render() uses a checkbox list when expanded is true and multiple is false');
// choices are translated
$t->diag('choices are translated');
$ws = new sfWidgetFormSchema();
$ws->addFormFormatter('stub', new FormFormatterStub());
$ws->setFormFormatterName('stub');
$w = new sfWidgetFormChoice(array('choices' => array('foo' => 'bar', 'foobar' => 'foo')));
$w->setParent($ws);
$dom->loadHTML($w->render('foo'));
$css = new sfDomCssSelector($dom);
$t->is($css->matchSingle('#foo option[value="foo"]')->getValue(), 'translation[bar]', '->render() translates the options');
$t->is($css->matchSingle('#foo option[value="foobar"]')->getValue(), 'translation[foo]', '->render() translates the options');
// ->getJavaScripts() ->getStylesheets()
$t->diag('->getJavaScripts() ->getStylesheets()');
$w = new sfWidgetFormChoice(array('choices' => array()));
$w->setOption('renderer_class', 'MyWidget');
$t->is($w->getJavaScripts(), array('/path/to/a/file.js'), '->getJavaScripts() returns the stylesheets of the renderer widget');
$t->is($w->getStylesheets(), array('/path/to/a/file.css' => 'all'), '->getStylesheets() returns the JavaScripts of the renderer widget');
// __clone()
$t->diag('__clone()');
开发者ID:vcgato29,项目名称:poff,代码行数:31,代码来源:sfWidgetFormChoiceTest.php

示例4: __construct

{
    public $translateSubjects = array();
    public function __construct()
    {
    }
    public function translate($subject, $parameters = array())
    {
        $this->translateSubjects[] = $subject;
        return sprintf('translation[%s]', $subject);
    }
}
class WidgetFormStub extends sfWidget
{
    public function __construct()
    {
    }
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {
        return sprintf('##%s##', __CLASS__);
    }
}
$t = new lime_test(2);
// ->render()
$t->diag('->render()');
$ws = new sfWidgetFormSchema();
$ws->addFormFormatter('stub', $formatter = new FormFormatterMock());
$ws->setFormFormatterName('stub');
$w = new sfWidgetFormDateRange(array('from_date' => new WidgetFormStub(), 'to_date' => new WidgetFormStub()));
$w->setParent($ws);
$t->is($w->render('foo'), 'translation[from ##WidgetFormStub## to ##WidgetFormStub##]', '->render() remplaces %from_date% and %to_date%');
$t->is($formatter->translateSubjects, array('from %from_date% to %to_date%'), '->render() translates the template option');
开发者ID:Phennim,项目名称:symfony1,代码行数:31,代码来源:sfWidgetFormDateRangeTest.php

示例5: sfWidgetFormSchema

$f = $w->getFields();
$t->is(array_keys($f1), array_keys($f), '__clone() clones embedded widgets');
foreach ($f1 as $name => $widget) {
    $t->ok($widget !== $f[$name], '__clone() clones embedded widgets');
    $t->ok($widget->getParent() === $w1, 'The parents hafe been changed');
    // avoid recursive dependencies at comparing
    $widget->setParent(null);
    $f[$name]->setParent(null);
    $t->ok($widget == $f[$name], '__clone() clones embedded widgets');
}
$format1->setTranslationCatalogue('french');
$formatters = $w1->getFormFormatters();
$t->is(count($formatters), 1, '__clone() returns a sfWidgetFormSchema that has the Formatters attached');
$t->is($formatters['testFormatter']->getTranslationCatalogue(), 'english', '__clone() clones formatters, so that changes to the original one have no effect to the cloned formatter.');
$w = new sfWidgetFormSchema();
$w->addFormFormatter('table', new sfWidgetFormSchemaFormatterTable($w));
$w->addFormFormatter('list', new sfWidgetFormSchemaFormatterList($w));
$w1 = clone $w;
$f1 = $w1->getFormFormatters();
$f = $w->getFormFormatters();
$t->is(array_keys($f1), array_keys($f), '__clone() clones form formatters');
foreach ($f1 as $key => $formFormatter) {
    $t->ok($formFormatter !== $f[$key], '__clone() clones form formatters');
    $t->is(get_class($formFormatter), get_class($f[$key]), '__clone() clones form formatters');
    $t->ok($formFormatter->getWidgetSchema() !== $f[$key]->getWidgetSchema(), '__clone() clones form formatters');
    $t->is(get_class($formFormatter->getWidgetSchema()), get_class($f[$key]->getWidgetSchema()), '__clone() clones form formatters');
}
// setDefaultFormFormatterName()
$t->diag('setDefaultFormFormatterName()');
$w = new sfWidgetFormSchema(array('w1' => $w1, 'w2' => $w2));
$t->isa_ok($w->getFormFormatter(), 'sfWidgetFormSchemaFormatterTable', 'setDefaultFormFormatterName() has the "sfWidgetFormSchemaFormatterTable" form formatter by default');
开发者ID:xmasclaux,项目名称:OpenGenepi,代码行数:31,代码来源:sfWidgetFormSchemaTest.php


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