From 5f5b235429f8dd9e32c647c12f9d31c776289787 Mon Sep 17 00:00:00 2001 From: nessunkim Date: Wed, 25 Jan 2017 01:50:51 +0900 Subject: [PATCH 1/5] Add support for rows attribute of textarea widget --- README.md | 13 +++++++++++++ playground/samples/widgets.js | 3 ++- src/components/widgets/TextareaWidget.js | 8 +++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f4cb9bfc20..bd49b74c54 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ A [live playground](https://mozilla-services.github.io/react-jsonschema-form/) i - [Form action buttons](#form-action-buttons) - [Help texts](#help-texts) - [Auto focus](#auto-focus) + - [Textarea rows](#textarea-rows) - [Placeholders](#placeholders) - [Form attributes](#form-attributes) - [Advanced customization](#advanced-customization) @@ -641,6 +642,18 @@ const uiSchema = { } ``` +### Textarea rows + +You can set initial height of a textarea widget by specifying a `ui:rows` uiSchema directive. + +```js +const schema = {type: "string"}; +const uiSchema = { + "ui:widget": "textarea", + "ui:rows": 15 +} +``` + ### Placeholders Text fields can benefit from placeholders by using the `ui:placeholder` uiSchema directive: diff --git a/playground/samples/widgets.js b/playground/samples/widgets.js index a918205985..a013af8bda 100644 --- a/playground/samples/widgets.js +++ b/playground/samples/widgets.js @@ -95,7 +95,8 @@ module.exports = { }, string: { textarea: { - "ui:widget": "textarea" + "ui:widget": "textarea", + "ui:rows": 5 }, color: { "ui:widget": "color" diff --git a/src/components/widgets/TextareaWidget.js b/src/components/widgets/TextareaWidget.js index 70aa3d9f40..88ac2c6456 100644 --- a/src/components/widgets/TextareaWidget.js +++ b/src/components/widgets/TextareaWidget.js @@ -4,6 +4,7 @@ import React, {PropTypes} from "react"; function TextareaWidget({ schema, id, + options, placeholder, value, required, @@ -15,7 +16,7 @@ function TextareaWidget({ }) { const _onChange = ({target: {value}}) => { return onChange(value === "" ? undefined : value); - }; + }; return (