Example #1
0
 public function prepareForm()
 {
     $form_attr = array('url' => $this->process_url, 'class' => "form-horizontal", 'role' => "form", 'method' => $this->method);
     $form_attr = array_merge($form_attr, $this->attributes);
     // See if we need a multipart form
     foreach ($this->fields as $field_obj) {
         if (in_array($field_obj->type, array('file', 'image'))) {
             $form_attr['files'] = 'true';
             break;
         }
     }
     // Set the form open and close
     if ($this->status == 'show') {
         $this->open = '<div class="form">';
         $this->close = '</div>';
     } else {
         $this->open = Form::open($form_attr);
         $this->close = Form::hidden('save', 1) . Form::close();
         if ($this->method == "GET") {
             $this->close = Form::hidden('search', 1) . Form::close();
         }
     }
     if (isset($this->validator)) {
         $this->errors = $this->validator->messages();
         $this->error .= implode('<br />', $this->errors->all());
     }
 }
Example #2
0
 public function __construct()
 {
     $this->tail = $this->tail = '<div class="row"><button type="submit" class="btn btn-primary">确定</button></div>' . Form::close();
 }
Example #3
0
 protected function buildForm()
 {
     $data = get_object_vars($this);
     $data['buttons'] = $this->button_container;
     $form_attr = array('url' => $this->process_url, 'class' => "", 'role' => "form", 'method' => $this->method);
     // See if we need a multipart form
     foreach ($this->fields as $field_obj) {
         if ($field_obj->type == 'file') {
             $form_attr['files'] = 'true';
             break;
         }
     }
     // Set the form open and close
     if ($this->status == 'show') {
         $data['form_begin'] = '<div class="form">';
         $data['form_end'] = '</div>';
     } else {
         $data['form_begin'] = Form::open($form_attr);
         $data['form_end'] = Form::hidden('save', 1) . Form::close();
         if ($this->method == "GET") {
             $data['form_end'] = Form::hidden('search', 1) . Form::close();
         }
     }
     if (isset($this->validator)) {
         $data['errors'] = $this->validator->messages();
     }
     $data['message'] = $this->process_status == "success" ? $this->message : '';
     $data['groups'] = $this->regroupFields($this->orderFields($this->fields));
     return View::make($this->view, $data);
 }
    /** 
     * Generate the button
     * @return string dataview
     */
    public function __toString()
    {
        $strTitle = '';
        $strLabel = $this->mIcon . ' ' . $this->mLabel;
        $strPrefix = '';
        $strSufix = '';
        if ($this->mSmall) {
            $strTitle = ' title="' . $this->mLabel . '"';
            $strLabel = $this->mIcon;
        }
        if ($this->mIsDeleteButton) {
            $strPrefix = Form::open(array('method' => 'delete', 'url' => $this->mDataUri, 'style' => 'display:inline!important;padding:0px;margin:0px'));
            $strSufix = Form::close();
            $this->enableConfirmation(trans('forms.confirm.text_delete'));
        }
        if ($this->mConfirmation) {
            $dialogTitle = trans('forms.confirm.title');
            $dialogMessage = $this->mConfirmationMessage;
            $dialogButtonOk = trans('forms.confirm.button_confirm');
            $dialogButtonCancel = trans('forms.confirm.button_cancel');
            $dialogAction = $this->mIsDeleteButton ? 'parentNode.submit()' : 'window.location.href=\'$this->mDataUri\'';
            $dialog = <<<EOD
                BootstrapDialog.show({ 
                    title:'{$dialogTitle}', message:'{$dialogMessage}', type:BootstrapDialog.TYPE_DEFAULT, 
                    buttons: [                        
                        {label:'{$dialogButtonCancel}', action:function(dialog){dialog.close();}}, 
                        {label:'{$dialogButtonOk}', cssClass:'btn-primary', action:function(dialog){ {$dialogAction}; dialog.close();}}, 
                    ]
                });
EOD;
            $this->mAttributes[] = 'onclick="' . trim($dialog) . '"';
            $this->mDataUri = '#';
        }
        return $strPrefix . '<a role="button" ' . 'href="' . $this->mDataUri . '" ' . 'class="' . implode(' ', $this->mClasses) . '" ' . 'style="' . implode(' ', $this->mStyles) . '" ' . implode(' ', $this->mAttributes) . $strTitle . '>' . $strLabel . '</a>' . $strSufix;
    }
Example #5
0
 public function formEnd()
 {
     return Form::close();
 }
Example #6
0
 /**
  * Create a Form close element
  */
 public function close()
 {
     return Form::close();
 }
Example #7
0
 /**
  * return a form with a nested action button
  * @param $url
  * @param $method
  * @param $name
  * @param  string $position
  * @param  array  $attributes
  * @return $this
  */
 public function formButton($url, $method, $name, $position = "BL", $attributes = array())
 {
     $attributes = array_merge(array("class" => "btn btn-default"), $attributes);
     $this->button_container[$position][] = Form::open(array('url' => $url, 'method' => $method)) . Form::submit($name, $attributes) . Form::close();
     return $this;
 }