ActiveAdmin表单:
我的问题:我无法获得包含多项选择文件的表单(
我试过了:
ActiveAdmin.register Foto do:
form :html => { :multipart => true } do |f|
f.inputs "Upload" do
f.input :foto, :as => :file
end
f.actions
end
end
这不起作用,然后我用两种形式制作了一个简单的html页面:
<!DOCTYPE doctype html>
<html>
<head>
</head>
<body>
<!--**not** work multiple choice files-->
<form accept-charset="UTF-8" action="#" enctype="multipart/form-data" method="post">
<input id="image" name="image" type="file"/>
</form>
<!--**great** work multiple choice files-->
<form accept-charset="UTF-8" action="#" method="post">
<input id="image" name="image" type="file" multiple=""/>
</form>
</body>
</html>
问题:如何将属性添加到多个输入字段?
我试过了:
f.input :foto, :as => :file, :html => {:multiple => ""}
f.input :foto, :as => :file, :html => {:multiple => ""}
f.input :foto, :as => :file, :html => {"multiple" => "multiple"}
f.input :foto, :as => :file, :html => {:multiple => :multiple}
这不起作用
请帮助我。答案 0 :(得分:3)
你应该使用
<main>
<h1>Mathador prototype</h1>
<router-outlet></router-outlet>
</main>
**app/app.routes.ts**
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './pages/home/home'
const appRoutes: Routes = [
{
path: '', component: HomeComponent
}
];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
**app/app.ts**
import { Component } from '@angular/core';
import '../../public/css/styles.css';
@Component({
selector : 'my-app',
templateUrl : './app.html',
styleUrls : ['./app.scss']
})
export class AppComponent {
}
**app/app.module.ts**
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { routing } from './app.routes';
// core
import { AppComponent } from './app';
// pages
import { HomeComponent } from './pages/home/home';
// components
import { Mathador } from './components/mathador/mathador';
@NgModule({
imports: [
BrowserModule,
routing
],
declarations: [
AppComponent,
HomeComponent,
Mathador
],
bootstrap: [ AppComponent ]
})
export class AppModule { }
**app/pages/home/home.ts**
import { Component } from '@angular/core';
@Component({
selector : 'my-home',
templateUrl : './home.html',
styleUrls : ['./home.scss']
})
export class HomeComponent {
constructor() {
// Do stuff
}
}
**app/pages/home/home.html**
<h1>home!</h1>
<Mathador></Mathador>
**app/components/mathador.html**
<div>transclusion succesfull!</div>
**app/components/mathador.ts**
// Importing core components
import {Component} from '@angular/core';
@Component({
selector : 'mathador',
templateUrl : './mathador.html'
})
export class Mathador {
constructor() { }
}