Skip to content

Commit

Permalink
fix #1031
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Apr 16, 2017
1 parent dd0f04f commit 8b66a74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,7 @@ class BootstrapTable extends Component {
field: props.dataField,
hiddenOnInsert: props.hiddenOnInsert,
keyValidator: props.keyValidator,
customInsertEditor: props.customInsertEditor,
// when you want same auto generate value and not allow edit, example ID field
autoValue: props.autoValue || false,
// for create editor, no params for column.editable() indicate that editor for new row
Expand All @@ -1061,6 +1062,7 @@ class BootstrapTable extends Component {
name: children.props.headerText || children.props.children,
field: children.props.dataField,
editable: children.props.editable,
customInsertEditor: children.props.customInsertEditor,
hiddenOnInsert: children.props.hiddenOnInsert,
keyValidator: children.props.keyValidator
} ];
Expand Down
15 changes: 13 additions & 2 deletions src/toolbar/InsertModalBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class InsertModalBody extends Component {
if (column.editable && column.editable.type === 'checkbox') {
const values = inputVal.split(':');
inputVal = dom.checked ? values[0] : values[1];
} else if (column.customInsertEditor) {
inputVal = inputVal || dom.getFieldValue();
}
}
newRow[column.field] = inputVal;
Expand All @@ -43,12 +45,21 @@ class InsertModalBody extends Component {
field,
name,
autoValue,
hiddenOnInsert
hiddenOnInsert,
customInsertEditor
} = column;
const attr = {
ref: field + i,
placeholder: editable.placeholder ? editable.placeholder : name
};
let fieldElement;

if (customInsertEditor) {
const { getElement } = customInsertEditor;
fieldElement = getElement(column, attr, 'form-control', ignoreEditable);
} else {
fieldElement = editor(editable, attr, format, '', undefined, ignoreEditable);
}

if (autoValue || hiddenOnInsert || !column.field) {
// when you want same auto generate value
Expand All @@ -61,7 +72,7 @@ class InsertModalBody extends Component {
return (
<div className='form-group' key={ field }>
<label>{ name }</label>
{ editor(editable, attr, format, '', undefined, ignoreEditable) }
{ fieldElement }
{ error }
</div>
);
Expand Down

0 comments on commit 8b66a74

Please sign in to comment.