Пример #1
0
 public function create($model_name, $options = array())
 {
     $defaults = array('action' => $this->controller->action, 'controller' => MvcInflector::tableize($model_name), 'public' => false);
     $options = array_merge($defaults, $options);
     $this->model_name = $model_name;
     $this->object = MvcObjectRegistry::get_object($model_name);
     $this->model = MvcModelRegistry::get_model($model_name);
     $this->schema = $this->model->schema;
     $object_id = !empty($this->object) && !empty($this->object->__id) ? $this->object->__id : null;
     $router_options = array('controller' => $options['controller'], 'action' => $options['action']);
     if ($object_id) {
         $router_options['id'] = $object_id;
     }
     $enctype = isset($options['enctype']) ? ' enctype="' . $options['enctype'] . '"' : '';
     $url = $options['public'] ? MvcRouter::public_url($router_options) : MvcRouter::admin_url($router_options);
     $html = '<form action="' . $url . '" method="post"' . $enctype . '>';
     if ($object_id) {
         $html .= '<input type="hidden" id="' . $this->input_id('hidden_id') . '" name="' . $this->input_name('id') . '" value="' . $object_id . '" />';
     }
     return $html;
 }