Swoole\Form::hidden PHP Method

hidden() static public method

隐藏项
static public hidden ( $name, $value = '', $attrArray = null ) : string
$name
$value
$attrArray
return string
    static function hidden($name, $value = '', $attrArray = null)
    {
        $attrStr = self::input_attr($attrArray);
        return "<input type='hidden' name='{$name}' id='{$name}' value='{$value}' {$attrStr} />";
    }

Usage Example

Example #1
0
 function edit()
 {
     if (!empty($_POST['name'])) {
         $inserts['name'] = $_POST['name'];
         $inserts['intro'] = $_POST['intro'];
         $msg['code'] = 0;
         if (empty($_POST['id'])) {
             $res = table("project")->put($inserts);
             $msg['message'] = $res ? "添加成功,ID: " . $res : "添加失败";
         } else {
             $res = table("project")->set(intval($_POST['id']), $inserts);
             $msg['message'] = $res ? "修改成功" : "修改失败";
         }
         $this->assign('msg', $msg);
     }
     if (empty($_GET)) {
         $form['name'] = \Swoole\Form::input('name');
         $form['intro'] = \Swoole\Form::input('intro');
         $this->assign('form', $form);
     } else {
         $id = (int) $_GET['id'];
         $res = table("project")->get($id)->get();
         $form['name'] = \Swoole\Form::input('name', $res['name']);
         $form['intro'] = \Swoole\Form::input('intro', $res['intro']);
         $form['id'] = \Swoole\Form::hidden('id', $res['id']);
     }
     $this->assign('form', $form);
     $this->display();
 }
All Usage Examples Of Swoole\Form::hidden