Skip to content

Commit

Permalink
Add SelectField to @redwoodjs/web (redwoodjs#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBroersma authored Apr 1, 2020
1 parent da28472 commit 4eb6b78
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/create-redwood-app-template/packages/web/src/form/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,21 @@ const TextField = (props) => {
)
}

// Renders a <select> field

const SelectField = (props) => {
const { register } = useFormContext()
const tagProps = inputTagProps(props)

return (
<select
{...tagProps}
id={props.id || props.name}
ref={register(props.validation || { required: false })}
/>
)
}

// Renders a <button type="submit">
const Submit = React.forwardRef((props, ref) => (
<button ref={ref} type="submit" {...props} />
Expand All @@ -221,5 +236,6 @@ export {
HiddenField,
TextAreaField,
TextField,
SelectField,
Submit,
}

0 comments on commit 4eb6b78

Please sign in to comment.