Get the form from the page with the given submit button text.

@param  string|null  $buttonText
@return \Symfony\Component\DomCrawler\Form

@throws \InvalidArgumentException
514355
protected function getForm($buttonText = null)
    {
        try {
            if ($buttonText) {
                return $this->crawler()->selectButton($buttonText)->form();
            }

            return $this->crawler()->filter('form')->form();
        } catch (InvalidArgumentException $e) {
            throw new InvalidArgumentException(
                "Could not find a form that has submit button [{$buttonText}]."
            );
        }
    }
388310
static function laraform($title, $name=null) {
        $el = new ElementButtonTwbs($name, ['value' => $title]);
        $el->addClass('btn');
        return $el;
    }
868697
private function parse_buttons( $buttons, $post = null )
    {
        $buttons = explode( '|', $buttons );

        $buttons = array_map( function ( $button ) use ( $post ) {

            $params = array_map( 'trim', explode( ',', $button ) );

            $button = [
                'title' => $params[0],
                'type'  => $params[1],
            ];

            if ( $button['type'] === 'postback' ) {
                $button['payload'] = $params[2];
            }

            if ( $button['type'] === 'web_url' ) {
                if ( $params[2] === 'permalink' ) {
                    $params[2] = get_permalink( $post );
                }

                if ( filter_var( $params[2], FILTER_VALIDATE_URL ) ) {
                    $button['url'] = $params[2];
                }
            }

            return $button;

        }, $buttons );

        return $buttons;
    }
1154721
public function getForm($documentClass = null)
    {
        if (null === $documentClass) {
            $documentClass = $this->getDocumentClass();
        }

        $builder = new AnnotationBuilder();
        $form = $builder->createForm($documentClass);

        $hasDocument = false;
        foreach ($form->getElements() as $element) {
            if (method_exists($element, 'setObjectManager')) {
                $element->setObjectManager($this->getDocumentManager());
                $hasDocument = true;
            } elseif (method_exists($element, 'getProxy')) {
                $proxy = $element->getProxy();
                if (method_exists($proxy, 'setObjectManager')) {
                    $proxy->setObjectManager($this->getDocumentManager());
                    $hasDocument = true;
                }
            }
        }

        if ($hasDocument) {
            $hydrator = new DoctrineObjectHydrator($this->getDocumentManager(), $documentClass);
            $form->setHydrator($hydrator);
        } else {
            $form->setHydrator(new ClassMethods());
        }

        $form->add([
            'type' => 'Zend\Form\Element\Csrf',
            'name' => 'csrf',
            'attributes' => [
                'id' => 'csrf',
            ],
        ]);

        $submitElement = new \Zend\Form\Element\Button('submit');
        $submitElement->setAttributes([
            'type' => 'submit',
            'class' => 'btn btn-primary',
        ]);
        $submitElement->setLabel('Salvar');
        $form->add($submitElement, [
            'priority' => -100,
        ]);

        $cancelarElement = new \Zend\Form\Element\Button('cancelar');
        $cancelarElement->setAttributes([
            'type' => 'button',
            'class' => 'btn btn-default',
            'onclick' => 'top.location=\''.$this->url()
                ->fromRoute($this->getActionRoute('list')).'\'',
        ]);
        $cancelarElement->setLabel('Cancelar');
        $form->add($cancelarElement, [
            'priority' => -100,
        ]);

        return $form;
    }
1348510
public function buttonSet($attachTo=NULL, $params=NULL) {
		return $this->addComponent(new Buttonset($this->js), $attachTo, $params);
	}
329394
protected function getFormField($xpath)
    {
        $fieldNode = $this->getCrawlerNode($this->getFilteredCrawler($xpath));
        $fieldName = str_replace('[]', '', $fieldNode->getAttribute('name'));

        $formNode = $this->getFormNode($fieldNode);
        $formId = $this->getFormNodeId($formNode);

        if (!isset($this->forms[$formId])) {
            $this->forms[$formId] = new Form($formNode, $this->getCurrentUrl());
        }

        if (is_array($this->forms[$formId][$fieldName])) {
            return $this->forms[$formId][$fieldName][$this->getFieldPosition($fieldNode)];
        }

        return $this->forms[$formId][$fieldName];
    }
598273
public function button($text, $url, $class = 'default', $parameters = array())
    {
        $this->message['buttons'][] = array(
            'text' => $this->container->translate($text, $parameters),
            'url' => $url,
            'class' => $class,
        );
        return $this;
    }
313733
public static function button($params = array()) {

        if( !is_array($params) )
        {
            throw new \InvalidArgumentException("Arguments is not a Array". print_r($params, true));
        }

        $o = "<button type='submit'";
        $o .= (isset($params['id'])) ? " id='{$params['id']}'" : '';
        $o .= (isset($params['name'])) ? " name='{$params['name']}'" : '';
        $o .= (isset($params['class'])) ? " class='{$params['class']}'" : '';
        $o .= (isset($params['onclick'])) ? " onclick='{$params['onclick']}'" : '';
        $o .= (isset($params['disabled'])) ? " disabled='{$params['disabled']}'" : '';
        $o .= (isset($params['style'])) ? " style='{$params['style']}'" : '';
        $o .= ">";
        $o .= (isset($params['iclass'])) ? "<i class='fa {$params['iclass']}'></i> " : '';
        $o .= (isset($params['value'])) ? "{$params['value']}" : '';
        $o .= "</button>\n";
        return $o;
    }
590040
protected function submitButton(SubmitButton $button)
    {
        $tag = new Tag('input');
        $tag->setAttribute('type', 'submit');

        return $this->parseTag($tag, $button);
    }
908764
public function staticPhp($text)
    {
        $textExplode      = explode('->', $text);
        $variableName     = str_replace('$', '', array_shift($textExplode));
        $variableVariable = $this->variables;

        if (isset($variableVariable[$variableName]) === false) {
            throw new \InvalidArgumentException(
                sprintf('variable %s does not exist', $variableName)
            );
        }

        $textExplode = array_map(
            function ($value) {
                return str_replace('()', '', $value);
            },
            $textExplode
        );

        $instance = $variableVariable[$variableName];
        $keys     = array_values($textExplode);
        $lastKey  = array_pop($keys);

        foreach ($textExplode as $key => $method) {
            if ($instance === null && $lastKey !== $key) {
                throw new \InvalidArgumentException(sprintf('method %s return null', $method));
            } elseif (false === method_exists($instance, $method)) {
                throw new \InvalidArgumentException(sprintf('method %s does not exist on %s', $method, $text));
            } else {
                $instance = $instance->$method();
            }
        }

        return $instance;
    }
758983
public function submitForm($buttonText, $formData = [])
    {
        foreach ($formData as $name => $value) {
            // Weird, but that's what you gotta do. :)
            $value = ['value' => [$value]];

            $element = $this->findByNameOrId($name);
            $tag = $element->name();

            if ($tag == 'input' && $element->attribute('type') == 'checkbox') {
                $element->click();
            } else {
                $element->postValue($value);
            }
        }

        $this->findByValue($buttonText)->submit();

        $this->updateCurrentUrl();

        return $this;
    }
846211
public function setTextBody($text) {
    if (!is_string($text)) {
      $error = sprintf("Plain text given is not a string (Actual type: %s).",
                       gettype($text));
      throw new \InvalidArgumentException($error);
    }
    $this->message->setTextbody($text);
  }
394804
public static function minLen($text, $minLen)
	{
	    if (is_array($minLen)) {
	        if (!isset($minLen['minLen'])) {
	            throw new \InvalidArgumentException('The $minLen argument must have "minLen" key');
	        }
	        $minLen = $minLen['minLen'];
	    }

	    return strlen($text) >= $minLen;
	}
956317
public function setHtmlBody($text) {
    if (!is_string($text)) {
      $error = sprintf("HTML text given is not a string (Actual type: %s).",
                       gettype($text));
      throw new \InvalidArgumentException($error);
    }
    $this->message->setHtmlbody($text);
  }
1223476
public function submitText(string $submitText)
    {
        /** @var Button $btn */
        $btn = $this->getButton($this->bottomLocation, $this->submitButtonKey);
        $btn->text($submitText);

        return $this;
    }
77797
public static function textGen(
        $text,
        Drawer $drawer = null,
        $format = 'png',
        $background = 'transparent',
        ImageResourceInterface $resource = null
    ) {
        $imanee = new Imanee(null, $resource);

        if ($drawer !== null) {
            $imanee->setDrawer($drawer);
        }

        $size = $imanee->resource->getTextGeometry($text, $imanee->getDrawer());
        $imanee->newImage($size['width'], $size['height'], $background);
        $imanee->setFormat($format);

        $imanee->placeText($text, Imanee::IM_POS_TOP_LEFT);

        return $imanee;
    }
133384
public function addInputText() : Input\Text
    {
        $input = new Input\Text($this->form, $this->name . '[]');
        $this->inputs[] = $input;

        return $input;
    }