2017-07-11 17 views
0

我使用Redux的形式一成不變的,我試圖做的,我使用FieldArray用於待辦事項簡單的待辦事項列表,終極版形式不變提交各領域

當提交表單時,我沒有得到的值索引,因爲它是隻讀的用戶和我使用div呈現。如何在提交表單時獲得索引的價值。 MyCustom組件的外觀應該如何。

<TableRow selectable={false} key={index}> 
    <TableRowColumn style={styles.item}> 
     <Field name={`${todo}.index`} component={MyCustom} val={index + 1} /> 
    </TableRowColumn> 
    <TableRowColumn style={styles.done}> 
     <Field name={`${todo}.done`} component={CheckBox} label=""/> 
    </TableRowColumn> 
    <TableRowColumn style={styles.description}> 
     <Field name={`${todo}.description`} component={Text}/> 
    </TableRowColumn> 
    <TableRowColumn style={styles.duration}> 
     <Field name={`${todo}.duration`} component={Duration} type="number" normalize={integer}/> 
    </TableRowColumn> 
    <TableRowColumn style={styles.delete}> 
     {/* <button type="button" title="X" onClick={() => fields.remove(index)}>X</button> */} 
     <IconButton onClick={() => fields.remove(index)}> 
     <DeleteIcon/> 
     </IconButton> 
    </TableRowColumn> 
    </TableRow> 

MyCustom

<div> 
    <span>{val}</span> 
    </div> 
+0

如果您沒有代碼示例,那麼您可能不會得到任何答案。 –

回答

0

index不是現場在這裏,它只是一個值。所以通過它作爲道具。

<MyCustom val={index + 1} /> 
+0

當改變$ {todo} .description時,我在表單提交時得到它,但我想將$ {todo} .index字段設置爲只讀,並在提交期間獲取該值。 – Maru