/** * Generate a default set of widgets. The default for each type is managed by definition of a subclass of the * appropriate widget. * * @param $scheme * @param string $formFile * @param null $language * @param string $formName * @param string $action * @param string $method * @return One_Form_Container_Form * @throws Exception */ private static function createDefaultForm($scheme, $formFile = 'form', $language = NULL, $formName = 'oneForm', $action = '', $method = 'post') { $formName = $formName ? $formName : $scheme->getName(); $form = new One_Form_Container_Form($formName, $action, 'post'); $form->setCfg('widgetsInContainer', 'One_Form_Container_Div'); foreach ($scheme->get('attributes') as $attribute) { $type = $attribute->getType(); $widgetClass = 'One_Form_Widget_Default_' . ucfirst($type); if (!class_exists($widgetClass)) { $widgetClass = 'One_Form_Widget_Default_Generic'; } $widget = new $widgetClass($attribute->getName(), $attribute->getName(), $attribute->getName()); // $widgetClass = $type->defaultWidgetClass(); // $widget = new $widgetClass($attribute->getName(), $attribute->getName(), $attribute->getName()); // switch ($attribute->getType()) { // case 'date': // $widget = new One_Form_Widget_Scalar_Date($attribute->getName(), $attribute->getName(), $attribute->getName()); // break; // case 'boolean': // $widget = new One_Form_Widget_Scalar_Checkbox($attribute->getName(), $attribute->getName(), $attribute->getName()); // break; // case 'text': // $widget = new One_Form_Widget_Scalar_Textarea($attribute->getName(), $attribute->getName(), $attribute->getName()); // break; // case 'string': // default: // $widget = new One_Form_Widget_Scalar_Textfield($attribute->getName(), $attribute->getName(), $attribute->getName()); // break; // } if ($widget) { $form->addWidget($widget); } } // add standard action buttons $form->addWidget(new One_Form_Widget_Defaultactions('action', 'action', 'action')); // $form->addWidget(new One_Form_Widget_Submit('action', 'action', 'update')); return $form; }