checkbox() static public method

多选按钮
static public checkbox ( string $name, array $option, string $default = null, boolean $self = false, array $attrArray = null, string $label_class = '' ) : string
$name string 此radio 的 name 标签
$option array 要制作radio 的数
$default string 如果要设定默认选择哪个数据 就在此填入默认的数据的值
$self boolean 设置为ture,option的值等于$value
$attrArray array html的属性 例如 class="x1"
$label_class string
return string
Ejemplo n.º 1
0
 function profile()
 {
     if ($_POST) {
         if (empty($_POST['nickname'])) {
             return Swoole\JS::js_back('昵称不能为空!');
         }
         if (!empty($_FILES['avatar']['name'])) {
             global $php;
             $php->upload->thumb_width = 90;
             $php->upload->thumb_height = 120;
             $php->upload->thumb_qulitity = 90;
             $php->upload->base_dir = "/static/uploads/avatar";
             $upfile = $php->upload->save('avatar');
             if ($upfile === false) {
                 return Swoole\JS::js_back('上传失败!');
             }
             $set['avatar'] = $_SESSION['user']['avatar'] = $upfile['thumb'];
         }
         $set['nickname'] = trim($_POST['nickname']);
         $set['intro'] = trim($_POST['intro']);
         $set['company'] = $_POST['company'];
         $set['blog'] = $_POST['blog'];
         $set['mobile'] = $_POST['mobile'];
         $set['sex'] = (int) $_POST['sex'];
         $set['education'] = (int) $_POST['education'];
         $set['skill'] = implode(',', $_POST['skill']);
         $set['php_level'] = (int) $_POST['php_level'];
         $u = model('UserInfo');
         $u->set($this->uid, $set);
         $_SESSION['user']['realname'] = $set['realname'];
         $_SESSION['user']['mobile'] = $set['mobile'];
         return Swoole\JS::js_back('修改成功!');
     } else {
         require WEBPATH . '/dict/forms.php';
         $_u = model('UserInfo');
         $u = $_u->get($this->uid)->get();
         $_skill = model('UserSkill')->getMap(array());
         $_forms['sex'] = Swoole\Form::radio('sex', $forms['sex'], $u['sex']);
         $_forms['education'] = Swoole\Form::select('education', $forms['education'], $u['education']);
         $_forms['skill'] = Swoole\Form::checkbox('skill', $_skill, $u['skill']);
         $_forms['level'] = Swoole\Form::radio('php_level', $forms['level'], $u['php_level']);
         $this->swoole->tpl->assign('user', $u);
         $this->swoole->tpl->assign('forms', $_forms);
         $this->swoole->tpl->display();
         //$this->view->showTrace();
     }
 }
Ejemplo n.º 2
0
 function guestbook()
 {
     if ($_POST) {
         if (empty($_POST['realname'])) {
             Swoole\JS::js_back('姓名不能为空!');
             exit;
         }
         if (empty($_POST['mobile'])) {
             Swoole\JS::js_back('电话不能为空!');
             exit;
         }
         unset($_POST['x'], $_POST['y']);
         $_POST['product'] = implode(',', $_POST['product']);
         $_POST['source'] = implode(',', $_POST['source']);
         $php->model->Guestbook->put($_POST);
         Swoole\JS::js_goto('注册成功!', 'guestbook.php');
     }
     if (!empty($_GET['id'])) {
         $gb = $php->model->Guestbook->get($_GET['id'])->get();
         $php->tpl->assign('gb', $gb);
         $php->tpl->display('guestbook_detail.html');
     } else {
         require 'dict/forms.php';
         $pager = null;
         $gets['page'] = empty($_GET['page']) ? 1 : $_GET['page'];
         $gets['pagesize'] = 12;
         $gets['select'] = "id,username,title,addtime";
         $gets['where'][] = "reply!=''";
         $list = $php->model->Guestbook->gets($gets, $pager);
         $_forms['title'] = Swoole\Form::radio('title', $forms['title'], null, true, array('empty' => '请选择称谓'));
         $_forms['age'] = Swoole\Form::select('age', $forms['age'], null, true, array('empty' => '请选择年龄阶段'));
         $_forms['ctime'] = Swoole\Form::select('ctime', $forms['ctime'], null, true, array('empty' => '请选择方便沟通的时间'));
         $_forms['product'] = Swoole\Form::checkbox('product', $forms['product'], null, true);
         $_forms['source'] = Swoole\Form::checkbox('source', $forms['source'], null, true);
         $pager = array('total' => $pager->total, 'render' => $pager->render());
         $php->tpl->assign('pager', $pager);
         $php->tpl->assign('forms', $_forms);
         $php->tpl->assign("list", $list);
         $php->tpl->display('guestbook.html');
     }
 }