kawax/laravel-laminas-form

View on GitHub
src/View/Concerns/Submit.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

namespace Revolution\LaminasForm\View\Concerns;

use Laminas\Form\ElementInterface;

trait Submit
{
    /**
     * @param  ElementInterface  $element
     * @return string
     */
    protected function submit(ElementInterface $element): string
    {
        if ($element->getAttribute('type') !== 'submit') {
            return $this->getView()->formElement($element);
        }

        $html = '<button type="submit" class="';
        $html .= $element->getAttribute('class') ?? self::DEFAULTS['submit'];
        $html .= '">';
        $html .= $element->getValue() ?? 'Submit';
        $html .= '</button>';

        return $html;
    }
}