當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。