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;
}