{"id":20159605,"url":"https://github.com/mosesesan/react-native-basic-form","last_synced_at":"2025-04-09T23:36:18.959Z","repository":{"id":36932906,"uuid":"226903093","full_name":"MosesEsan/react-native-basic-form","owner":"MosesEsan","description":"React Native Basic Form by Moses Esan","archived":false,"fork":false,"pushed_at":"2023-06-06T07:39:39.000Z","size":84,"stargazers_count":3,"open_issues_count":5,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T13:11:19.275Z","etag":null,"topics":["authentication","form-validation","javascript","programming","react","react-context-api","react-forms","react-native"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MosesEsan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-09T15:22:53.000Z","updated_at":"2020-07-09T12:34:07.000Z","dependencies_parsed_at":"2022-08-08T18:30:27.782Z","dependency_job_id":null,"html_url":"https://github.com/MosesEsan/react-native-basic-form","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MosesEsan%2Freact-native-basic-form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MosesEsan%2Freact-native-basic-form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MosesEsan%2Freact-native-basic-form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MosesEsan%2Freact-native-basic-form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MosesEsan","download_url":"https://codeload.github.com/MosesEsan/react-native-basic-form/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248130862,"owners_count":21052814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","form-validation","javascript","programming","react","react-context-api","react-forms","react-native"],"created_at":"2024-11-14T00:09:10.593Z","updated_at":"2025-04-09T23:36:18.929Z","avatar_url":"https://github.com/MosesEsan.png","language":"JavaScript","readme":"# React Native Basic Form\n\nA simple React Native Form component with TextInput (including multiline), DropDown and Image fields.\",\n\n\n### Installation\n\n```bash\n$ npm install --save react-native-basic-form\n\n#dependencies (Reat Native CLI only \u003c v0.16)\nnpm i --save react-native-vector-icons  \nreact-native link react-native-vector-icon\n```\n\n## Dependencies Setup (for Expo projects)\n\n```bash\nexpo install @react-native-community/datetimepicker\n```\n\n\n### Form\nShows a form\n\n```javascript\nimport React from 'react';\nimport {View} from 'react-native';\nimport Form, {TYPES} from 'react-native-basic-form';\n\nexport default function Example(props) {\n    const [loading, setLoading] = useState(false);\n\n    const options = [\n        {label:\"Basic\", value:1},\n        {label:\"Premium\", value:2}\n    ];\n    \n    //Used in EDIT MODE\n    const initialData = {\n        \"image\": \"http://res.cloudinary.com/ddv9bxonm/image/upload/v1585512850/ib9c0dml4dlksi8xgvob.jpg\"\n        \"email\": \"Johnsmith@yahoo.com\",\n        \"password\": \"thispasswordisencrypted\",\n        \"account_type\": 1, //Basic account, see options\n        \"price\": 20,\n        \"about_me\": \"Blah blah blah.....\",\n        \"start_date\": \"2020-04-17T21:00:00.000Z\",\n        \"end_date\": \"2020-04-17T21:00:00.000Z\",\n    };\n\n    const fields = [\n        {name: 'image', label: 'Profile Image', required: true, type: TYPES.Image},\n        {name: 'email', label: 'Email Address', required: true, type: TYPES.Email},\n        {name: 'username', label: 'Username', required: true, autoCapitalize: \"none\", autoCorrect: false},\n        {name: 'password', label: 'Password', required: true, secure: true},\n        {name: 'account_type', label: 'Account Type', required: true, type: TYPES.Dropdown, options: options},\n        {name: 'price', label: 'ENTRANCE FEE', required: true, type:TYPES.Number},\n        {name: 'about_me', label: 'About Me', required: true, multiline: true},\n        [\n            //group to appear side by side\n            {name: 'start_date', label: 'START DATE', required: true, type: TYPES.Date},\n            {name: 'end_date', label: 'END DATE', required: true, type: TYPES.Date}\n        ]\n    ];\n\n    async function onSubmit(data) {\n        setLoading(true);\n\n        console.log(data)\n        ....\n    }\n    \n    async function showImagePicker() {\n        try{\n            //return - cancelled or error or uri\n            //return {cancelled:true}\n            //return {error:\"error message}\n            //return {uri:...}\n        }catch(e){\n            return {error:e}\n        }\n    }\n\n    render() {\n        return (\n            \u003cView\u003e\n                \u003cForm\n                    title={\"Register\"} //this is the button title\n                    fields={fields}\n                    initialData={initialData} //used in edit mode\n                    onSubmit={onSubmit}\n                    loading={loading}\n                    showImagePicker={showImagePicker}\n                    style={{}}/\u003e\n            \u003c/View\u003e\n        );\n    };\n};\n```\n#### Field Types\n| Type | Notes |\n| ---- | ----- |\n| Text | Default|\n| Number | |\n| Dropdown | |\n| Image | |\n| Email | Sets the keyboard to display email-address type |\n\n\n#### Field Props\n| Prop | Value | Required/Optional | Description | Default |\n| ---- | ----- | ----------------- | ----------- | ----------- |\n| name | string | optional | The field title | \"\" |\n| label | string | optional | The field label | \"\" |\n| required | bool | optional | Whether the field is required | false |\n| secure | bool | optional | Whether the value should be masked | false |\n| type | string | optional | The field type | TYPES.Text (see above) |\n| autoCapitalize | string | optional | The field auto capitalize setting | \"sentences\" |\n| autoCorrect | bool | optional | The field auto correct setting | true |\n| clearButtonMode | bool | optional | When the clear button should appear on the right side of the text view. | never |\n| editable | bool | optional | If false, text is not editable. | true |\n\n\n\n#### Props\n| prop | value | required/optional | description | default |\n| ---- | ----- | ----------------- | ----------- | ----------- |\n| title | string | optional | The button title | \"Submit\" |\n| fields | object | required | the fields to show | [] |\n| initialData | object | option | the initial data, can be used in EDIT mode, the keys should match the fields key | [] |\n| onSubmit | function | required | the function to call when the submit button is pressed | null |\n| showImagePicker | function | optional | the function to call when the image is tapped | null |\n| loading | boolean | optional | if true, button is disabled and shows a loading icon | false |\n| style | object | optional | the style for the container | {} |\n| buttonStyle | object | optional | the style for the button | {} |\n| keyboardShouldPersistTaps | string | optional | Determines when the keyboard should stay visible after a tap.| 'handled' |\n\nkeyboardShouldPersistTaps:https://facebook.github.io/react-native/docs/scrollview#keyboardshouldpersisttaps\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmosesesan%2Freact-native-basic-form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmosesesan%2Freact-native-basic-form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmosesesan%2Freact-native-basic-form/lists"}