public function openForm($method, $action, array $options = []): Htmlable
    {
        // Initialize the form state
        if ($this->formState !== null || $this->currentForm !== null)
        {
            throw new RuntimeException('You cannot open another form before closing the previous one');
        }
        $this->formState = app()->make(FormState::class);
        $this->formState->setModel($options['model'] ?? null);
        $this->formState->setHideErrors($options['hideErrors'] ?? false);

        // Create a form element with sane defaults
        $this->currentForm = Form::create();

        // Handle form method consequences (token / hidden method field)
        //
        // If Laravel needs to spoof the form's method, we'll append a hidden
        // field containing the actual method
        //
        // On any other method that get, the form needs a CSRF token
        $method = strtoupper($method);

        if (\in_array($method, ['DELETE', 'PATCH', 'PUT'], true))
        {
            $this->currentForm = $this->currentForm->addChild($this->hidden('_method', $method));
            $method = 'POST';
        }

        if ($method !== 'GET')
        {
            $this->currentForm = $this->currentForm->addChild($this->token());
        }

        if ($options['files'] ?? false)
        {
            $this->currentForm = $this->currentForm->acceptsFiles();
        }

        return $this->currentForm
            ->method($method)
            ->action($action)
            ->addClassIf($options['inline'] ?? false, 'form-inline')
            ->attributesIf($options['attributes'] ?? false, $options['attributes'] ?? [])
            ->open();
    }
public function openForm($method, $action, array $options = []): Htmlable
    {
        // Initialize the form state
        if ($this->formState !== null || $this->currentForm !== null)
        {
            throw new RuntimeException('You cannot open another form before closing the previous one');
        }
        $this->formState = app()->make(FormState::class);
        $this->formState->setModel($options['model'] ?? null);
        $this->formState->setHideErrors($options['hideErrors'] ?? false);

        // Create a form element with sane defaults
        $this->currentForm = Form::create();

        // Handle form method consequences (token / hidden method field)
        //
        // If Laravel needs to spoof the form's method, we'll append a hidden
        // field containing the actual method
        //
        // On any other method that get, the form needs a CSRF token
        $method = strtoupper($method);

        if (\in_array($method, ['DELETE', 'PATCH', 'PUT'], true))
        {
            $this->currentForm = $this->currentForm->addChild($this->hidden('_method', $method));
            $method = 'POST';
        }

        if ($method !== 'GET')
        {
            $this->currentForm = $this->currentForm->addChild($this->token());
        }

        if ($options['files'] ?? false)
        {
            $this->currentForm = $this->currentForm->acceptsFiles();
        }

        return $this->currentForm
            ->method($method)
            ->action($action)
            ->addClassIf($options['inline'] ?? false, 'form-inline')
            ->attributesIf($options['attributes'] ?? false, $options['attributes'] ?? [])
            ->open();
    }
public function openForm ( $ method , $ action , array $ options = [ ] ) : Htmlable { // Initialize the form state if ( $ this -> formState !== null || $ this -> currentForm !== null ) { throw new RuntimeException ( 'You cannot open another form before closing the previous one' ) ; } $ this -> formState = app ( ) -> make ( FormState :: class ) ; $ this -> formState -> setModel ( $ options [ 'model' ] ?? null ) ; $ this -> formState -> setHideErrors ( $ options [ 'hideErrors' ] ?? false ) ; // Create a form element with sane defaults $ this -> currentForm = Form :: create ( ) ; // Handle form method consequences (token / hidden method field) // // If Laravel needs to spoof the form's method, we'll append a hidden // field containing the actual method // // On any other method that get, the form needs a CSRF token $ method = strtoupper ( $ method ) ; if ( \ in_array ( $ method , [ 'DELETE' , 'PATCH' , 'PUT' ] , true ) ) { $ this -> currentForm = $ this -> currentForm -> addChild ( $ this -> hidden ( '_method' , $ method ) ) ; $ method = 'POST' ; } if ( $ method !== 'GET' ) { $ this -> currentForm = $ this -> currentForm -> addChild ( $ this -> token ( ) ) ; } if ( $ options [ 'files' ] ?? false ) { $ this -> currentForm = $ this -> currentForm -> acceptsFiles ( ) ; } return $ this -> currentForm -> method ( $ method ) -> action ( $ action ) -> addClassIf ( $ options [ 'inline' ] ?? false , 'form-inline' ) -> attributesIf ( $ options [ 'attributes' ] ?? false , $ options [ 'attributes' ] ?? [ ] ) -> open ( ) ; }
Open a form

@param string $method  The method to target for form action
@param string $action  The form action
@param array  $options A set of options for the form

Valid options are:

- files      => bool    Does the form accept files
- inline     => bool    Shall we render an inline form (Bootstrap specific)
- model      => mixed   The model to bind to the form
- hideErrors => bool    Hide field errors
- attributes => array   Attributes to set on the form element

@return \Illuminate\Contracts\Support\Htmlable
@throws \Exception When trying to open a form before closing the previous one
Open a form