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


PHP Text::addFilter方法代码示例

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


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

示例1: testArrayedValues

 public function testArrayedValues()
 {
     $model = new FakeModel();
     $values = array('integer' => '3 14', 'test1' => array(2 => 'foo', 3 => 'bar'), 'test2' => array('en' => 'baz', 'nl' => 123.4), 'test3' => array(array(0 => 'doubleArrayed', 1 => array(0 => 'tripleArrayed'))), 'not_in_form' => array('some_value'));
     $form = new Form();
     $text = new Text('integer');
     $text->addFilter('int');
     $form->add($text);
     $form->add(new Text('test1[]'));
     $form->add(new Text('test1[]'));
     $text = new Text('test2[en]');
     $text->addValidator(new PresenceOf());
     $form->add($text);
     $text = new Text('test2[nl]');
     $text->addFilter('int');
     $form->add($text);
     $form->add(new Text('test3[0][]'));
     $form->add(new Text('test3[0][1][]'));
     $form->bind($values, $model);
     $this->assertTrue($form->isValid());
     $this->assertTrue(!isset($model->not_in_form));
     $this->assertEquals('3 14', $form->getValue('integer'));
     $this->assertEquals(314, $model->integer);
     $this->assertEquals($model->test1[0], $form->getValue('test1[2]'));
     $this->assertEquals($model->test1[1], $form->getValue('test1[3]'));
     $this->assertNull($form->getValue('test1[]'));
     $this->assertNull($form->getValue('test1[1]'));
     $this->assertEquals($model->test2['en'], $form->getValue('test2[en]'));
     $this->assertEquals(123.4, $form->getValue('test2[nl]'));
     $this->assertEquals(1234, $model->test2['nl']);
     $this->assertNull($form->getValue('test2[en][notexsiting]'));
     $this->assertEquals($model->test3[0][0], $form->getValue('test3[0][0]'));
     $this->assertEquals($model->test3[0][1][0], $form->getValue('test3[0][1][0]'));
 }
开发者ID:vegas-cmf,项目名称:forms,代码行数:34,代码来源:FormTest.php

示例2: testForm

 public function testForm()
 {
     $form = new Form();
     $form->add(new Text("name"));
     $form->add(new Text("telephone"));
     $this->assertEquals(count($form), 2);
     $this->assertEquals($form->count(), 2);
     $form = new Form();
     $name = new Text("name");
     $name->addFilter('trim');
     $name->addValidator(new StringLength(array('max' => 10)));
     $form->add($name);
     $this->assertTrue($form->isValid(array('name' => 'phalcon    ')));
     $this->assertEquals($form->getValues(), array('name' => 'phalcon'));
     $this->assertEquals($form->getValues(NULL, Form::VALUES_RAW), array('name' => 'phalcon    '));
 }
开发者ID:UqiOnline,项目名称:cphalcon7,代码行数:16,代码来源:FormsTest.php


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