Esempio n. 1
0
 public function testDivOrSpanElementForFormBuilder()
 {
     $this->setUpAssetConfig();
     $form = Form::make()->open('contact', ['method' => 'post', 'action' => Url::sitePath('contact/add'), 'role' => 'form', 'style' => 'width:500px;margin-top:35px;float:left;'])->addElement('openTag', 'div_1', ['style' => 'border:1px solid red;height:40px;'])->addElement('text', 'I am Inside Div 1', ["class" => "col-sm-2 control-label", "style" => "width:100%;"])->addElement('closeTag', 'div_1')->addElement('openTag', 'div_2', ['style' => 'border:1px solid red;height:40px;'])->addElement('text', 'I am Inside Div 2', ["class" => "col-sm-2 control-label", "style" => "width:100%;"])->addElement('closeTag', 'div_2')->createForm()->close();
     $formString = preg_replace("/\r\n|\r|\n|\t/", '', trim("<form name='contact' method='post' action='http://localhost/cygnite/contact/add' role='form' style='width:500px;margin-top:35px;float:left;' >\n\t\t\t<div name='div_1_1331' style='border:1px solid red;height:40px;'  />\n\t\t\t<input name='I am Inside Div 1' class='col-sm-2 control-label' style='width:100%;' type='text'  />\n\t\t\t</div>\n\t\t\t<div name='div_2_1224' style='border:1px solid red;height:40px;'  />\n\t\t\t<input name='I am Inside Div 2' class='col-sm-2 control-label' style='width:100%;' type='text'  />\n\t\t\t</div>\n\t\t\t</form>"));
     // It works though But we cannot Test it because it generate random name for Div or Span Element
     // For Example [name='div_2_1224' or name='div_1_1331']
 }
 /**
  *  Build form and return object
  * @return ProductForm
  */
 public function buildForm()
 {
     $id = isset($this->model->id) ? $this->model->id : '';
     // Below code is to display validation errors below the input box
     if (is_object($this->validator)) {
         // Set your custom errors
         //$this->validator->setCustomError('column.error', 'Your Custom Error Message');
     }
     $this->open("Product", ["method" => "post", "id" => "uniform", "role" => "form", "action" => Url::sitePath("product/{$this->action}/{$id}/"), "style" => "width:500px;margin-top:35px;float:left;"])->addElement("label", "Product Name", ["class" => "col-sm-2 control-label", "style" => "width:100%;"])->addElement("text", "product_name", ["value" => isset($this->model->product_name) ? $this->model->product_name : "", "class" => "form-control"])->addElement("label", "Category", ["class" => "col-sm-2 control-label", "style" => "width:100%;"])->addElement("text", "category", ["value" => isset($this->model->category) ? $this->model->category : "", "class" => "form-control"])->addElement("label", "Description", ["class" => "col-sm-2 control-label", "style" => "width:100%;"])->addElement("text", "description", ["value" => isset($this->model->description) ? $this->model->description : "", "class" => "form-control"])->addElement("label", "Validity", ["class" => "col-sm-2 control-label", "style" => "width:100%;"])->addElement("text", "validity", ["value" => isset($this->model->validity) ? $this->model->validity : "", "class" => "form-control"])->addElement("label", "Price", ["class" => "col-sm-2 control-label", "style" => "width:100%;"])->addElement("text", "price", ["value" => isset($this->model->price) ? $this->model->price : "", "class" => "form-control"])->addElement("label", "Created At", ["class" => "col-sm-2 control-label", "style" => "width:100%;"])->addElement("text", "created_at", ["value" => isset($this->model->created_at) ? $this->model->created_at : "", "class" => "form-control"])->addElement("label", "Updated At", ["class" => "col-sm-2 control-label", "style" => "width:100%;"])->addElement("text", "updated_at", ["value" => isset($this->model->updated_at) ? $this->model->updated_at : "", "class" => "form-control"])->addElement("submit", "btnSubmit", ["value" => "Save", "class" => "btn btn-primary", "style" => "margin-top:15px;"])->close()->createForm();
     return $this;
 }
Esempio n. 3
0
 /**
  *  Build form and return object
  * @return CommentForm
  */
 public function buildForm()
 {
     $id = isset($this->model->id) ? $this->model->id : '';
     // Fllowing code is to display validation errors below the input box
     if (is_object($this->validation)) {
         $this->validator = $this->validation;
         // Errors will displayed below to inputs
         // Set your custom errors
         //$this->validator->setCustomError('column_name_error', 'Custom Error');
     }
     $this->open("CommentController", array("method" => "post", "id" => "uniform", "role" => "form", "action" => Url::sitePath("comment/type/{$id}/{$this->segment}"), "style" => "width:500px;margin-top:35px;float:left;"))->addElement("label", "P Id", array("class" => "col-sm-2 control-label", "style" => "width:100%;"))->addElement("text", "p_id", array("value" => isset($this->model->p_id) ? $this->model->p_id : "", "class" => "form-control"))->addElement("label", "F Name", array("class" => "col-sm-2 control-label", "style" => "width:100%;"))->addElement("text", "f_name", array("value" => isset($this->model->f_name) ? $this->model->f_name : "", "class" => "form-control"))->addElement("label", "Post", array("class" => "col-sm-2 control-label", "style" => "width:100%;"))->addElement("text", "post", array("value" => isset($this->model->post) ? $this->model->post : "", "class" => "form-control"))->addElement("label", "F Image", array("class" => "col-sm-2 control-label", "style" => "width:100%;"))->addElement("text", "f_image", array("value" => isset($this->model->f_image) ? $this->model->f_image : "", "class" => "form-control"))->addElement("label", "Date Created", array("class" => "col-sm-2 control-label", "style" => "width:100%;"))->addElement("text", "date_created", array("value" => isset($this->model->date_created) ? $this->model->date_created : "", "class" => "form-control"))->addElement("label", "Userip", array("class" => "col-sm-2 control-label", "style" => "width:100%;"))->addElement("text", "userip", array("value" => isset($this->model->userip) ? $this->model->userip : "", "class" => "form-control"))->addElement("submit", "btnSubmit", array("value" => "Save", "class" => "btn btn-primary", "style" => "margin-top:15px;"))->close()->createForm();
     return $this;
 }
Esempio n. 4
0
 /**
  *  Build form and return object
  * @return Registration
  */
 public function buildForm()
 {
     $id = isset($this->model->id) ? $this->model->id : '';
     $this->open('users', array('method' => 'post', 'action' => Url::sitePath('products/type/' . $id . '/' . $this->segment), 'role' => 'form', 'style' => 'width:500px;margin-top:35px;float:left;'))->addElement('label', 'Product Type', array('class' => 'col-sm-2 control-label', 'style' => 'width:37.667%;'))->addElement('text', 'product_type', array('value' => isset($this->model->product_type) ? $this->model->product_type : '', 'class' => 'form-control'))->addElement('label', 'Name', array('class' => 'col-sm-2 control-label'))->addElement('text', 'name', array('value' => isset($this->model->name) ? $this->model->name : '', 'class' => 'form-control'))->addElement('label', 'Price', array('class' => 'col-sm-2 control-label'))->addElement('text', 'price', array('value' => isset($this->model->price) ? $this->model->price : '', 'class' => 'form-control'))->addElement('submit', 'btnSubmit', array('value' => 'Save', 'class' => 'btn btn-primary', 'style' => 'margin-top:15px;'))->close()->createForm();
     return $this;
 }