Collective\Html\FormBuilder::open PHP Method

open() public method

Open up a new HTML form.
public open ( array $options = [] ) : Illuminate\Support\HtmlString
$options array
return Illuminate\Support\HtmlString
    public function open(array $options = [])
    {
        $method = array_get($options, 'method', 'post');
        // We need to extract the proper method from the attributes. If the method is
        // something other than GET or POST we'll use POST since we will spoof the
        // actual method since forms don't support the reserved methods in HTML.
        $attributes['method'] = $this->getMethod($method);
        $attributes['action'] = $this->getAction($options);
        $attributes['accept-charset'] = 'UTF-8';
        // If the method is PUT, PATCH or DELETE we will need to add a spoofer hidden
        // field that will instruct the Symfony request to pretend the method is a
        // different method than it actually is, for convenience from the forms.
        $append = $this->getAppendage($method);
        if (isset($options['files']) && $options['files']) {
            $options['enctype'] = 'multipart/form-data';
        }
        // Finally we're ready to create the final form HTML field. We will attribute
        // format the array of attributes. We will also add on the appendage which
        // is used to spoof requests for this PUT, PATCH, etc. methods on forms.
        $attributes = array_merge($attributes, array_except($options, $this->reserved));
        // Finally, we will concatenate all of the attributes into a single string so
        // we can build out the final form open statement. We'll also append on an
        // extra value for the hidden _method field if it's needed for the form.
        $attributes = $this->html->attributes($attributes);
        return $this->toHtmlString('<form' . $attributes . '>' . $append);
    }

Usage Example

 /**
  * Return the opening form tag.
  *
  * @param array $options
  * @return string
  */
 public function open(array $options = [])
 {
     if ($url = $this->object->getOption('url')) {
         $options['url'] = $url;
     }
     return $this->html->open($options);
 }
All Usage Examples Of Collective\Html\FormBuilder::open