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;
 }
示例#2
0
 /**
  * Returns a `FormItem` based on the type of the `Column`.
  *
  * @param Model     $model  The `Model` which contains given `Column`.
  * @param Column    $column The `Column` to create a `FormItem` for.
  * @param \Eloquent $item   The instance to retrieve information from for filling the `FormItem`.
  *
  * @return FormItem The created `FormItem`.
  */
 private function createFromType(Model $model, Column $column, $item)
 {
     $result = null;
     switch ($column->getType()) {
         case Type::TEXT:
         case Type::TARRAY:
         case Type::SIMPLE_ARRAY:
         case Type::JSON_ARRAY:
         case Type::OBJECT:
         case Type::BLOB:
             $result = new TextAreaFormItem();
             break;
         case Type::INTEGER:
         case Type::SMALLINT:
         case Type::BIGINT:
             $result = new IntegerFormItem();
             break;
         case Type::DECIMAL:
         case Type::FLOAT:
             $result = new NumberFormItem();
             break;
         case Type::BOOLEAN:
             $result = new CheckboxFormItem();
             break;
         case Type::DATE:
             $result = new DateFormItem();
             break;
         case Type::DATETIME:
         case Type::DATETIMETZ:
             $result = new DateTimeFormItem();
             break;
         case Type::TIME:
             $result = new TimeFormItem();
             break;
         case Type::STRING:
         case Type::GUID:
         default:
             $result = new TextFormItem();
             break;
     }
     $columnName = $column->getName();
     $result->setName($columnName);
     $result->setLabel(Lang::trans($this->aujaConfigurator->getColumnDisplayName($model, $columnName)));
     if ($item != null && isset($item->{$columnName})) {
         $result->setValue($item->{$columnName});
     }
     return $result;
 }