码迷,mamicode.com
首页 > 其他好文 > 详细

phalcon: 表单

时间:2016-09-29 01:33:54      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:

以实例为说明:

controller

<?php
use \Phalcon\Forms\Form;
use \Phalcon\Forms\Element\Text;
use \Phalcon\Forms\Element\Select;
use \Phalcon\Mvc\Controller,
	Phalcon\Validation\Validator\PresenceOf,
    Phalcon\Validation\Validator\StringLength;
class FormController extends Controller
{
	public function indexAction()
	{
		$form = new Form();

              //例子一:
		$form->add(new Text("name", array(
			"maxlength" => 20,
			"placeholder"=>‘you name‘
		)));

               //例子二:
		$form->add(new Text("telphone"));

                //例子三:
               //例子三我有不明白的地方,该怎么调用他的验证。
		$passwd = new Text("passwd");
		$passwd->addValidator(new PresenceOf(array(
			‘message‘ => ‘The passwd is required‘
		)));
		$passwd->addValidator(new StringLength(array(
			‘min‘ => 10,
			‘messageMinimum‘ => ‘The passwd is too short‘
		)));
		$form->add($passwd);

		
		
		$this->view->pick("form/form");
		$this->view->form=$form;
	}

	
}
?>    

  

phtml

<html>
<title>aaa</title>
<body>

<?php echo $this->tag->form("form/test");?>

<?php echo $form->render("name") ?>
<br>
<?php echo $form->render("telphone", array("maxlength"=>20, "placeholder"=>"you telphone"));?>
<br>
<?php echo $form->render("passwd") ?>




<br>
<?php echo $this->tag->submitButton("login");?>
</form>

</body>
</html>

  

 

phalcon: 表单

标签:

原文地址:http://www.cnblogs.com/achengmu/p/5918218.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!