예제 #1
0
파일: myForm.php 프로젝트: huoybb/movie
 public static function buildFormFromModel(myModel $object)
 {
     $form = new Form($object);
     $fields = [];
     foreach ($object->columnMap() as $column) {
         if (!in_array($column, ['created_at', 'updated_at', 'id'])) {
             $form->add(new \Phalcon\Forms\Element\Text($column));
             $fields[] = $column;
         }
     }
     $form->fields = $fields;
     $form->add(new \Phalcon\Forms\Element\Submit('修改'));
     return $form;
 }
예제 #2
0
 protected function buildFormFromModel(myModel $model)
 {
     if ($model->id) {
         $form = new Form($model);
     } else {
         $form = new Form();
     }
     $fields = [];
     foreach ($model->columnMap() as $column) {
         if (!in_array($column, ['created_at', 'updated_at', 'id', 'password', 'remember_token'])) {
             $form->add(new \Phalcon\Forms\Element\Text($column));
             $fields[] = $column;
         }
     }
     $form->fields = $fields;
     if ($model->id) {
         $form->add(new \Phalcon\Forms\Element\Submit('修改'));
     } else {
         $form->add(new \Phalcon\Forms\Element\Submit('增加'));
     }
     return $form;
 }