FOF30\Factory\BasicFactory::form PHP Метод

form() публичный Метод

Creates a new Form object
public form ( string $name, string $source, string $viewName, array $options = [], boolean $replace = true, boolean $xpath = false ) : Form | null
$name string The name of the form.
$source string The form source filename without path and .xml extension e.g. "form.default" OR raw XML data
$viewName string The name of the view you're getting the form for.
$options array Options to the Form object
$replace boolean Should form fields be replaced if a field already exists with the same group/name?
$xpath boolean An optional xpath to search for the fields.
Результат FOF30\Form\Form | null The loaded form or null if the form filename doesn't exist
    public function form($name, $source, $viewName, array $options = array(), $replace = true, $xpath = false)
    {
        // Get a new form instance
        $form = new Form($this->container, $name, $options);
        // If $source looks like raw XML data, parse it directly
        if (strpos($source, '<form') !== false) {
            if ($form->load($source, $replace, $xpath) === false) {
                throw new FormLoadData();
            }
            return $form;
        }
        $formFileName = $this->getFormFilename($source, $viewName);
        if (empty($formFileName)) {
            if ($this->scaffolding) {
                $scaffolding = new LayoutBuilder($this->container);
                $xml = $scaffolding->make($source, $viewName);
                if (!is_null($xml)) {
                    return $this->form($name, $xml, $viewName, $options, $replace, $xpath);
                }
            }
            return null;
        }
        if ($form->loadFile($formFileName, $replace, $xpath) === false) {
            throw new FormLoadFile($source);
        }
        return $form;
    }