首页 > 代码库 > phalcon: 表单
phalcon: 表单
以实例为说明:
controller
<?phpuse \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: 表单
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。