Exemplo n.º 1
0
 public function generateForm()
 {
     $this->property->action = $this->property->action ?: Manager::getCurrentURL();
     \Maestro\Utils\MUtil::setIfNull($this->property->method, 'POST');
     \Maestro\Utils\MUtil::setIfNull($this->style->width, "100%");
     $this->property->role = "form";
     $fields = $buttons = $help = $tools = "";
     $fields = $this->generateFields();
     $buttons = $this->generateButtons();
     $help = $this->generateHelp();
     if ($this->tools != NULL) {
         mdump('has tools');
         $tools = $this->generateTools();
     }
     // menubar
     if ($this->property->menubar) {
         $menubar = PainterControl::generate($this->property->menubar);
     }
     // por default, o método de submissão é POST
     \Maestro\Utils\MUtil::setIfNull($this->property->method, "POST");
     if ($this->property->onsubmit) {
         PainterControl::getPage()->onSubmit($this->property->onsubmit, $this->property->id);
     }
     // se o form tem fields com validators, define onSubmit
     $validators = '';
     if (count($this->property->toValidate)) {
         PainterControl::getPage()->onSubmit("\$('#{$this->property->id}').form('validate')", $this->property->id);
         $validators = implode(',', $this->property->bsValidator);
     }
     //mdump($fields);
     // obtem o codigo html via template
     $inner = PainterControl::fetch('painter/formdialog', $this, ['fields' => $fields, 'buttons' => $buttons, 'help' => $help, 'tools' => $tools, 'validators' => $validators, 'menubar' => $menubar]);
     return $inner;
 }
Exemplo n.º 2
0
 public static function mformdialog($control)
 {
     //$c = new FormDialog($control);
     //return $c->generate();
     $html = PainterControl::fetch('painter/formdialog', $control);
     return $html;
 }
Exemplo n.º 3
0
 public function generate()
 {
     if ($this->property->load) {
         $this->setData($this->property->load);
     }
     // panel
     $panel = new MBaseControl('mpanel');
     $panel->property->title = $this->property->title;
     $panel->style->width = $this->style->width;
     $panel->property->close = $this->property->close;
     $panel->property->class = $this->property->class;
     //mdump('--');
     //mdump($this->style->border);
     $panel->options->border = isset($this->style->border) ? $this->style->border : false;
     PainterControl::generate($panel);
     //gera o panel para obter todos os atributos
     // propriedades
     $this->property->action = $this->property->action ?: Manager::getCurrentURL();
     \Maestro\Utils\MUtil::setIfNull($this->property->method, 'POST');
     \Maestro\Utils\MUtil::setIfNull($this->style->width, "100%");
     $this->property->role = "form";
     // define o layout com base na classe bootstrap do form
     \Maestro\Utils\MUtil::setIfNull($this->property->layout, "horizontal");
     $this->setClass("form-{$this->property->layout}");
     // neste tema o mform é constituído de 3 blocos principais: fields, buttons e help
     $fields = $this->generateFields();
     $buttons = $this->generateButtons();
     $help = $this->generateHelp();
     // toolbar
     if ($this->toolbar) {
         $this->toolbar->tag = 'header';
         $this->toolbar->setClass('datagrid-toolbar');
         $toolbar = PainterControl::generate($this->toolbar);
     }
     // menubar
     if ($this->property->menubar) {
         $menubar = PainterControl::generate($this->property->menubar);
     }
     // por default, o método de submissão é POST
     \Maestro\Utils\MUtil::setIfNull($this->property->method, "POST");
     if ($this->property->onsubmit) {
         PainterControl::getPage()->onSubmit($this->property->onsubmit, $this->property->id);
     }
     // se o form tem fields com validators, define onSubmit
     $validators = '';
     if (count($this->property->toValidate)) {
         PainterControl::getPage()->onSubmit("\$('#{$this->property->id}').form('validate')", $this->id);
         $validators = implode(',', $this->property->bsValidator);
     }
     // obtem o codigo html via template
     $result = PainterControl::fetch('mform', $this, ['panel' => $panel, 'fields' => $fields, 'buttons' => $buttons, 'help' => $help, 'validators' => $validators, 'menubar' => $menubar, 'toolbar' => $toolbar]);
     return $result;
 }