最后更新 : 2013-11-21 18:11:44
选择语言 :
Form 表单输出辅助类
通常在视图页面里使用
Form::open($action=null , $attributes = null)
<?php
echo Form::open( '/test' );
echo Form::open( '/test' , array ( 'method' => 'get' ));
|
Form::close()
Form::input($name, $value = null, array $attributes = null)
<?php
echo Form::input( 'test' , 1 );
echo Form::input( 'test' , 1 , array ( 'size' =>20) );
echo Form::input( null , 1 , array ( 'id' => 'test' , onclick=> 'alert(1)' ) );
|
Form::hidden($name, $value = null, array $attributes = null);
<?php
echo Form::hidden( 'test' ,123);
|
Form::password($name, $value = null, array $attributes = null);
<?php
echo Form::password( 'test' ,123);
|
Form::file($name , array $attributes = null);
<?php
echo Form::file( 'test' );
|
Form::checkbox($name, $value = null, $checked = false, array $attributes = null)
<?php
echo Form::checkbox( 'test[]' , 1 );
echo Form::checkbox( 'test[]' , 1 , true );
|
Form::radio($name, $value = null, $checked = false, array $attributes = null)
<?php
echo Form::radio( 'test' , 1 );
echo Form::radio( 'test' , 1 , true );
|
Form::textarea($name, $body = '', array $attributes = null, $double_encode = false)
<?php
echo Form::textarea( 'test' , 'content' );
|
Form::select($name, array $options = null, $selected = null, array $attributes = null)
<?php
$op = array (
'' => '请选择' ,
1 => '栏目一' ,
2 => '栏目二' ,
3 => '栏目三' ,
);
echo Form::select( 'test' , $op , 1 );
|
多选效果:
$op = array (
1 => '栏目一' ,
2 => '栏目二' ,
3 => '栏目三' ,
);
echo Form::select( 'test[]' , $op , array (1,3) , array ( 'size' =>4 , 'multiple' => 'multiple' ) );
|
分组功能效果:
$op = array (
'分组一' => array (
1 => '栏目一' ,
2 => '栏目二' ,
3 => '栏目三' ,
),
'分组二' => array (
4 => '栏目四' ,
5 => '栏目五' ,
),
);
echo Form::select( 'test' , $op , 2 );
|
Form::submit($name , $value, array $attributes = null)
<?php
echo Form::submit(null , '提交' );
|
Form::image($name, $value, array $attributes = null, $index = false)
<?php
echo Form::image( 'test' , null , array ( 'src' => 'test.gif' ) );
|
Form::button($name, $body, array $attributes = null)
<?php
echo Form::image( 'test' , '按钮' );
|
Form::label($input, $text = null, array $attributes = null)
echo Form::label( 'username' , '用户名' );
echo Form::label( 'test' , Form::checkbox( 'test' , 1 , false , array ( 'id' => 'test' ) ) . '测试' );
|