public static function mformdialog($control)
 {
     //$c = new FormDialog($control);
     //return $c->generate();
     $html = PainterControl::fetch('painter/formdialog', $control);
     return $html;
 }
 public function generate()
 {
     // dialog
     $dialog = new Dialog($this->baseControl);
     $dialog->setId($this->property->id . '_dialog');
     $dialog->property->title = $this->property->title;
     $dialog->property->close = $this->property->close;
     $dialog->property->onClose = $this->property->onClose;
     $dialog->property->class = $this->property->class;
     $dialog->style->width = $this->style->width;
     $dialog->options = $this->options;
     if ($this->buttons) {
         $dialog->options->buttons = '#' . $this->property->id . '_buttons';
     }
     if ($this->tools) {
         $dialog->options->toolbar = '#' . $this->property->id . '_tools';
     }
     $dialog->property->state = "open";
     $dialog->options->border = isset($this->style->border) ? $this->style->border : true;
     $this->options = new \stdClass();
     // remove as options do form
     $dialog->inner = $this->generateForm();
     return PainterControl::generate($dialog);
 }
Exemple #3
0
 public function generateControl($control)
 {
     return PainterControl::generate($control);
 }
Exemple #4
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;
 }