Exemplo n.º 1
0
 /**
  * Opens up magically a form
  *
  * @param  string $typeAsked  The form type asked
  * @param  array  $parameters Parameters passed
  * @return string             A form opening tag
  */
 public function open($typeAsked, $parameters)
 {
     $method = 'POST';
     $secure = false;
     $action = array_get($parameters, 0);
     $attributes = array_get($parameters, 1);
     // If classic form
     if ($typeAsked == 'open') {
         $type = Former::$defaultFormType;
     } else {
         // Look for HTTPS form
         if (str_contains($typeAsked, 'secure')) {
             $typeAsked = str_replace('secure', null, $typeAsked);
             $secure = true;
         }
         // Look for file form
         if (str_contains($typeAsked, 'for_files')) {
             $typeAsked = str_replace('for_files', null, $typeAsked);
             $attributes['enctype'] = 'multipart/form-data';
         }
         // Calculate form type
         $type = trim(str_replace('open', null, $typeAsked), '_');
         if (!in_array($type, $this->availableTypes)) {
             $type = Former::$defaultFormType;
         }
     }
     // Add the final form type
     $attributes = Helpers::addClass($attributes, 'form-' . $type);
     // Store it
     $this->type = $type;
     // Open the form
     return \Form::open($action, $method, $attributes, $secure);
 }
Exemplo n.º 2
0
 /**
  * Opens up magically a form
  *
  * @param  string $typeAsked  The form type asked
  * @param  array  $parameters Parameters passed
  * @return string             A form opening tag
  */
 public function open($typeAsked, $parameters)
 {
     $action = array_get($parameters, 0);
     $method = array_get($parameters, 1, 'POST');
     $attributes = array_get($parameters, 2, array());
     $secure = array_get($parameters, 3, false);
     // If classic form
     if ($typeAsked == 'open') {
         $type = Config::get('default_form_type');
     } else {
         // Look for HTTPS form
         if (str_contains($typeAsked, 'secure')) {
             $typeAsked = str_replace('secure', null, $typeAsked);
             $secure = true;
         }
         // Look for file form
         if (str_contains($typeAsked, 'for_files')) {
             $typeAsked = str_replace('for_files', null, $typeAsked);
             $attributes['enctype'] = 'multipart/form-data';
         }
         // Calculate form type
         $type = trim(str_replace('open', null, $typeAsked), '_');
         if (!in_array($type, $this->availableTypes)) {
             $type = Config::get('default_form_type');
         }
     }
     // Add the final form type
     $attributes = Helpers::addClass($attributes, 'form-' . $type);
     // Store it
     $this->type = $type;
     // Fetch errors if asked for
     if (Config::get('fetch_errors')) {
         Former::withErrors();
     }
     // Open the form
     $this->action = $action;
     $this->method = $method;
     $this->attributes = $attributes;
     $this->secure = $secure;
     return $this;
 }
Exemplo n.º 3
0
 /**
  * Return html.
  *
  * @return string
  */
 public function show()
 {
     return self::view('indicator', ['tag' => $this->tag, 'attributes' => Helpers::addClass($this->attributes, $this->class . ' ' . $this->type), 'message' => $this->message]);
 }
Exemplo n.º 4
0
 /**
  * Add a class to the current field
  *
  * @param string $class The class to add
  */
 public function addClass($class)
 {
     $this->attributes = Helpers::addClass($this->attributes, $class);
 }