コード例 #1
0
 /**
  * main method it detect status, exec action and build output
  *
  * @param string $method
  */
 public function build($method = 'form')
 {
     $this->process_url = $this->process_url . $this->hash;
     //detect form status (output)
     if (isset($this->model)) {
         $this->status = $this->model->loaded ? "modify" : "create";
     } else {
         $this->status = "create";
     }
     //build fields
     $this->build_fields();
     //process only if instance is a dataform
     if (is_a($this, 'dataform_library')) {
         //build buttons
         $this->build_buttons();
         //sniff action
         if (isset($_POST) && url_helper::value('process')) {
             $this->action = $this->status == "modify" ? "update" : "insert";
         }
         //process
         $this->process();
     }
     $method = 'build_' . $method;
     $this->output = $this->{$method}();
 }