コード例 #1
0
ファイル: MFormDialog.php プロジェクト: elymatos/expressive
 public function generateFields()
 {
     if (count($control->fields->controls) == 1) {
         $style = "style=border-spacing:0px;";
     }
     $fields = "<div class='mFormContainer' {$style}>";
     $control = $this->fields;
     if ($control->hasItems()) {
         foreach ($control->controls as $field) {
             if ($field instanceof MBaseControl) {
                 if ($field->tag == 'mhiddenfield') {
                     $fields .= $field->generate();
                 } else {
                     $mfieldlabel = new MBaseControl('mfieldlabel', ['id' => $field->property->id, 'text' => $field->property->label]);
                     if ($this->property->layout == 'horizontal') {
                         //$mfieldlabel->setClass($this->labelClass);
                     }
                     $label = $mfieldlabel->generate();
                     if ($label) {
                         $formGroup = "<div class=\"mFormColumn\">{$label}</div>" . "<div class=\"mFormColumn\">{$field->generate()}</div>";
                     } else {
                         $formGroup = "<div class=\"mFormColumn\">{$field->generate()}</div>";
                     }
                     if ($field->tag == 'mvcontainer' || $field->tag == 'mhcontainer') {
                         $fields .= "</div>";
                         $fields .= $field->generate();
                         $fields .= "<div class='mFormContainer'>";
                     } else {
                         // usa a classe form-group do bootstrap
                         $fields .= "<div class=\"mFormRow\">{$formGroup}</div>";
                     }
                 }
             }
         }
     }
     $fields .= "</div>";
     return $fields;
 }
コード例 #2
0
 public function cloneStyle(MBaseControl $control)
 {
     $this->style = $control->getStyle();
 }
コード例 #3
0
ファイル: MForm.php プロジェクト: elymatos/expressive
 public function generate()
 {
     // 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;
     $panel->generate();
     //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 = $buttons = $help = "";
     if ($this->fields != NULL) {
         $fields = $this->generateFields();
     }
     if ($this->buttons != NULL) {
         $buttons = $this->generateButtons();
     }
     if ($this->help != NULL) {
         $help = $this->generateHelp();
     }
     // toolbar
     if ($this->toolbar) {
         $this->toolbar->tag = 'header';
         $this->toolbar->setClass('datagrid-toolbar');
         $toolbar = $this->toolbar->generate();
     }
     // menubar
     if ($this->property->menubar) {
         $menubar = $this->property->menubar->generate();
     }
     // por default, o método de submissão é POST
     \Maestro\Utils\MUtil::setIfNull($this->property->method, "POST");
     if ($this->property->onsubmit) {
         $this->page->onSubmit($this->property->onsubmit, $this->property->id);
     }
     // se o form tem fields com validators, define onSubmit
     $validators = '';
     if (count($this->property->toValidate)) {
         $this->page->onSubmit("\$('#{$this->property->id}').form('validate')", $this->id);
         $validators = implode(',', $this->property->bsValidator);
     }
     // obtem o codigo html via template
     $result = $this->painter->fetch('mform', $this, ['panel' => $panel, 'fields' => $fields, 'buttons' => $buttons, 'help' => $help, 'validators' => $validators, 'menubar' => $menubar, 'toolbar' => $toolbar]);
     return $result;
 }