Adding/submitting dynamic fields

Adding/submitting dynamic fields

luisrmzluisrmz Posts: 4Questions: 1Answers: 0

I'm experiencing a bug with the add() API function. I am adding 2 fields each time the user clicks on a button; all of the new fields have unique names.

I am able to add/remove the fields without a problem, but when I try to submit, Editor gives me the error: multiIds is not defined. This was stemming from a field's multiGet call, so I patched it to fall back on an empty array. Now DataTables' _fnGetObjectDataFn function is giving an error, saying data is not defined. I patched this so that if data is undefined, it'll return null instead of failing. Now I can submit my form.

My question is, is this how adding fields dynamically should work? Or is something wrong with my implementation? Here is how I am adding them, where fField and lField are strings of the field names. This editor is not tied to a table, it's standalone.

standaloneEditor
    .add([{
        label: 'First name',
        name: fField,
        type: 'text',
        attr: {
            placeholder: 'First name *'
        }
    }, {
        label: 'Last name',
        name: lField,
        type: 'text',
        attr: {
            placeholder: 'Last name *'
        }
    }])
    .field(fField).focus();

Answers

  • luisrmzluisrmz Posts: 4Questions: 1Answers: 0

    Upon further inspection, Editor is not submitting the value from the fields correctly and just putting null instead. So the _fnGetObjectDataFn patch does not work correctly, but just silences the error. So I believe the problem resides in that function, but I'm not sure why it's being used if I'm using a standalone editor, so there isn't an initial object to get data from.

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Its a bug I'm afraid. When the field was being added, Editor wasn't checking to see if it is already in edit mode or not. If so, then it needs to initialise the field for the items being edited (even in standalone mode).

    I've fixed this locally now and it will be in Editor 1.7.3.

    I can e-mail a copy to you if you like - is the address used for your account here the right one to use?

    Allan

  • luisrmzluisrmz Posts: 4Questions: 1Answers: 0

    Yes, that's the my current email address. A copy of the fix would be great.

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Just sent you an e-mail with it.

    Regards,
    Allan

  • maliwikmaliwik Posts: 55Questions: 5Answers: 1

    I'm getting this bug as well - when is 1.7.3 going to be out?

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Next week - hopefully in the first half.

    Allan

This discussion has been closed.