Add attributes to fileUpload
From the mailing list:
Is there a good reason that a fileUpload cannot be given attributes like the other components?
E.g. def text(value: String, func: String => Any, attrs: (String, String)*): Elem = ...
But def fileUpload(func: FileParamHolder => Unit): Elem = ...
I think it would be easy to add that support.
This is what we already have:
def fileUpload(func: FileParamHolder => Unit): Elem = {
val f2: FileParamHolder => Unit = fp =>
if (fp.file != null && fp.file.length > 0) func(fp)
fmapFunc(BinFuncHolder(f2))(name => <input type="file" name={name}/>)
}
Let's add:
def fileUpload(func: FileParamHolder => Unit, attrs: (String, String)*): Elem = {
val f2: FileParamHolder => Unit = fp =>
if (fp.file != null && fp.file.length > 0) func(fp)
fmapFunc(BinFuncHolder(f2))(name => attrs.foldLeft(<input type="file" name={name}/>)(_ % _))
}
If you don't see any issues I would open a ticket and add that.
Is there a good reason that a fileUpload cannot be given attributes like the other components?
E.g. def text(value: String, func: String => Any, attrs: (String, String)*): Elem = ...
But def fileUpload(func: FileParamHolder => Unit): Elem = ...
I think it would be easy to add that support.
This is what we already have:
def fileUpload(func: FileParamHolder => Unit): Elem = {
val f2: FileParamHolder => Unit = fp =>
if (fp.file != null && fp.file.length > 0) func(fp)
fmapFunc(BinFuncHolder(f2))(name => <input type="file" name={name}/>)
}
Let's add:
def fileUpload(func: FileParamHolder => Unit, attrs: (String, String)*): Elem = {
val f2: FileParamHolder => Unit = fp =>
if (fp.file != null && fp.file.length > 0) func(fp)
fmapFunc(BinFuncHolder(f2))(name => attrs.foldLeft(<input type="file" name={name}/>)(_ % _))
}
If you don't see any issues I would open a ticket and add that.
Leave a comment