Exemple #1
0
 public function create($modelName, $item = null, ModelConfig $config = null)
 {
     $page = new Page();
     $header = new PageHeader();
     $header->setText('Create ' . $modelName);
     if ($item != null && isset($item->id)) {
         $model = $this->aujaConfigurator->getModel($modelName);
         $displayField = $this->aujaConfigurator->getDisplayField($model, $config);
         $header->setText('Edit ' . (isset($item->{$displayField}) ? $item->{$displayField} : $modelName));
         $deleteButton = new Button();
         $deleteButton->setText(Lang::trans('Delete'));
         $deleteButton->setConfirmationMessage(Lang::trans('Are you sure?'));
         $deleteButton->setTarget(URL::route($this->aujaRouter->getDeleteName($modelName), $item->id));
         $deleteButton->setMethod('delete');
         $header->addButton($deleteButton);
     }
     $page->addPageComponent($header);
     $form = new Form();
     $action = $item == null || !isset($item->id) ? URL::route($this->aujaRouter->getStoreName($modelName)) : URL::route($this->aujaRouter->getUpdateName($modelName), $item->id);
     $form->setAction($action);
     $form->setMethod($item == null ? 'POST' : 'PUT');
     $model = $this->aujaConfigurator->getModel($modelName);
     $visibleFields = $this->aujaConfigurator->getVisibleFields($model, $config);
     foreach ($visibleFields as $columnName) {
         $column = $model->getColumn($columnName);
         $formItem = $this->formItemFactory->getFormItem($model, $column, $item);
         $form->addFormItem($formItem);
     }
     $submit = new SubmitFormItem();
     $submit->setText(Lang::trans('Submit'));
     $form->addFormItem($submit);
     $page->addPageComponent($form);
     return $page;
 }
 public function create($title, $target)
 {
     $result = new Form();
     $result->setAction($target);
     $result->setMethod('POST');
     $header = new FormHeader();
     $header->setText($title);
     $result->addFormItem($header);
     $usernameTextFormItem = new TextFormItem();
     $usernameTextFormItem->setName('email');
     $usernameTextFormItem->setLabel(Lang::trans('Email address'));
     $result->addFormItem($usernameTextFormItem);
     $passwordFormItem = new PasswordFormItem();
     $passwordFormItem->setName('password');
     $passwordFormItem->setLabel(Lang::trans('Password'));
     $result->addFormItem($passwordFormItem);
     $submitFormItem = new SubmitFormItem();
     $submitFormItem->setText(Lang::trans('Login'));
     $result->addFormItem($submitFormItem);
     return $result;
 }