Skip to content

Commit e99268d

Browse files
committed
Close #64: Add support for hidden inputs
1 parent bd2c82a commit e99268d

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/components/containers.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,13 @@ export function FormRowControls(props) {
108108
}
109109

110110
export function FormRow(props) {
111+
let className = 'rjf-form-row';
112+
113+
if (props.hidden)
114+
className += ' rjf-form-row-hidden';
115+
111116
return (
112-
<div className="rjf-form-row">
117+
<div className={className}>
113118
<FormRowControls {...props} />
114119
<div className="rjf-form-row-inner">
115120
{props.children}

src/components/form.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@ export function Label(props) {
2222
export function FormInput({label, help_text, error, inputRef, ...props}) {
2323

2424
if (props.type === 'string')
25-
props.type = 'text'
25+
props.type = 'text';
2626

2727
if (inputRef)
2828
props.ref = inputRef;
2929

3030
if (props.value === null)
3131
props.value = '';
3232

33+
let wrapperProps = {};
34+
if (props.type == 'hidden')
35+
wrapperProps['style'] = {display: 'none'};
36+
3337
return (
34-
<div>
38+
<div {...wrapperProps}>
3539
<Label label={label} required={props.required} />
3640
<div className={error ? "rjf-input-group has-error" : "rjf-input-group"}>
3741
<input {...props} />

src/ui.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ function FormField(props) {
5858
if (props.schema.widget) {
5959
if (props.schema.widget === 'multiselect' && props.parentType !== 'array') {
6060
// pass
61+
} else if (props.schema.widget === 'hidden') {
62+
type = 'string';
6163
} else {
6264
type = props.schema.widget;
6365
}
@@ -79,6 +81,8 @@ function FormField(props) {
7981
InputField = FormDateTimeInput;
8082
}
8183
inputProps.type = props.schema.format;
84+
} else if (props.schema.widget === 'hidden') {
85+
inputProps.type = 'hidden';
8286
} else {
8387
inputProps.type = 'text';
8488
}
@@ -177,6 +181,7 @@ export function getStringFormRow(args) {
177181
onRemove={removable ? (e) => onRemove(name) : null}
178182
onMoveUp={onMoveUp}
179183
onMoveDown={onMoveDown}
184+
hidden={schema.widget === 'hidden'}
180185
>
181186
<FormField
182187
data={data}

0 commit comments

Comments
 (0)