Backend\Core\Engine\Form::__construct PHP 메소드

__construct() 공개 메소드

public __construct ( string $name = null, string $action = null, string $method = 'post', boolean $useToken = true, boolean $useGlobalError = true )
$name string Name of the form.
$action string The action (URL) whereto the form will be submitted, if not provided it will be autogenerated.
$method string The method to use when submitting the form, default is POST.
$useToken boolean Should we automagically add a formtoken?
$useGlobalError boolean Should we automagically show a global error?
    public function __construct($name = null, $action = null, $method = 'post', $useToken = true, $useGlobalError = true)
    {
        if (BackendModel::getContainer()->has('url')) {
            $this->URL = BackendModel::getContainer()->get('url');
        }
        if (BackendModel::getContainer()->has('header')) {
            $this->header = BackendModel::getContainer()->get('header');
        }
        $this->useGlobalError = (bool) $useGlobalError;
        // build a name if there wasn't one provided
        $name = $name === null ? \SpoonFilter::toCamelCase($this->URL->getModule() . '_' . $this->URL->getAction(), '_', true) : (string) $name;
        // build the action if it wasn't provided
        $action = $action === null ? '/' . $this->URL->getQueryString() : (string) $action;
        // call the real form-class
        parent::__construct($name, $action, $method, $useToken);
        // add default classes
        $this->setParameter('id', $name);
        $this->setParameter('class', 'fork-form submitWithLink');
    }