mirror of
https://github.com/dzeiocom/FormManager.git
synced 2025-04-22 19:02:15 +00:00
Added new input !
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
54e38f30a3
commit
762b1fec32
30
src/modules/CheckboxInput.ts
Normal file
30
src/modules/CheckboxInput.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import InputIdentity from './Interfaces/InputIdentity';
|
||||||
|
import DefaultInput from './DefaultInput';
|
||||||
|
import { toBoolean } from '../Functions';
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @class FMDateInput
|
||||||
|
* @extends {FMInput}
|
||||||
|
*/
|
||||||
|
export default class CheckboxInput extends DefaultInput {
|
||||||
|
|
||||||
|
public setValue(value: any) {
|
||||||
|
this.element.checked = this.formatValue(value)
|
||||||
|
}
|
||||||
|
public getValue(): boolean {
|
||||||
|
return this.element.checked
|
||||||
|
}
|
||||||
|
public formatValue(value: any): boolean {
|
||||||
|
value = toBoolean(value)
|
||||||
|
if (typeof value === "undefined") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
public static identity: InputIdentity = {
|
||||||
|
input: CheckboxInput,
|
||||||
|
type: "checkbox"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user