Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dist/ReactstrapFormikInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ var ReactstarpFormikInput = function ReactstarpFormikInput(_ref) {
return React.createElement(
FormGroup,
null,
React.createElement(
props.label ? React.createElement(
Label,
{ "for": props.id, className: "label-color" },
props.label
),
) : null,
React.createElement(Input, Object.assign({}, props, fields, { invalid: Boolean(touched[fields.name] && errors[fields.name]) })),
touched[fields.name] && errors[fields.name] ? React.createElement(
FormFeedback,
Expand Down
11 changes: 6 additions & 5 deletions dist/ReactstrapSelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ var ReactstrapSelectInput = function ReactstrapSelectInput(_ref) {

var error = errors[field.name];
var touch = touched[field.name];
var label = props.label ? React.createElement(
Label,
{ "for": props.inputprops.id, className: "label-color" },
props.label
) : null;
return React.createElement(
FormGroup,
null,
React.createElement(
Label,
{ "for": props.inputprops.id, className: "label-color" },
props.label
),
label,
React.createElement(
Input,
Object.assign({ id: props.inputprops.id }, field, props, { type: "select",
Expand Down
4 changes: 2 additions & 2 deletions src/components/ReactstrapFormikInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const ReactstarpFormikInput = (
...props
}) => (
<FormGroup>
<Label for={props.id} className={"label-color"}>{props.label}</Label>
{ props.label ? <Label for={props.id} className={"label-color"}>{props.label}</Label> : null }
<Input {...props} {...fields} invalid={Boolean(touched[fields.name] && errors[fields.name])}/>
{touched[fields.name] && errors[fields.name] ? <FormFeedback>{errors[fields.name]}</FormFeedback> : ''}
</FormGroup>
);
export default ReactstarpFormikInput;
export default ReactstarpFormikInput;
5 changes: 3 additions & 2 deletions src/components/ReactstrapSelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ const ReactstrapSelectInput = ({
}) => {
let error = errors[field.name];
let touch = touched[field.name];
let label = props.label ? <Label for={props.inputprops.id} className={"label-color"}>{props.label}</Label> : null;
return (
<FormGroup>
<Label for={props.inputprops.id} className={"label-color"}>{props.label}</Label>
{label}
<Input id={props.inputprops.id} {...field} {...props} type="select"
invalid={Boolean(touched[field.name] && errors[field.name])}
placeholder="Test">
Expand All @@ -37,4 +38,4 @@ const ReactstrapSelectInput = ({
)
};

export default ReactstrapSelectInput;
export default ReactstrapSelectInput;
10 changes: 9 additions & 1 deletion src/stories/InputStory.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ export default () => (
id="password"
/>
</Col>
<Col xs="12">
<Field
type="text"
name="no_label_text"
component={TextField}
id="no_label_text"
/>
</Col>
<Col xs="12">
<button
type="submit"
Expand All @@ -66,4 +74,4 @@ export default () => (
</Form>
)}
/>
);
);
14 changes: 13 additions & 1 deletion src/stories/SelectStory.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ export default () => (
}}>
</Field>
</Col>
<Col xs="12">
<Field
name="no_label_country"
component={SelectInput}
inputprops={{
name: 'no_label_country',
id: 'no_label_country',
options: ['India', 'USA', 'UK', 'Saudi Arabia'],
defaultOption: "Country"
}}>
</Field>
</Col>
<Col xs="12">
<button
type="submit"
Expand All @@ -70,4 +82,4 @@ export default () => (
</Form>
)}
/>
);
);