本文整理汇总了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]'));
}
示例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 '));
}