2 Checkboxes in Custom Field behaves not correct

2 Checkboxes in Custom Field behaves not correct

VolkhardVVolkhardV Posts: 20Questions: 5Answers: 0

Hello,

1) at https://customer.vogeler-ag.de/vag/test/test3.html is a demonstration
2) you can mark the 1st record "Name1" and goto "Ändern". In editor-form you see the fields Name and Mitglieder
3) Mitglieder is the custom field-extension which shows a 3-column-table "BillByCategory","Billable" and "Amount"
4) the Billable-Checkbox in the first row should be checked (the data=true for this) - but it is not checked.
5) when you tick the Billable or BillbyCategory checkboxes the other one is changing the state.

Do you know why for the topics ? Can anyone help?

best regards

Volkhard

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin

    Hi Volkhard,

    This is a tricky one! I believe it is because of the difference between true and "true" (i.e. a primitive boolean, or a string). The options are set up as { label: '', value: true }, but when the value is set in the form, it is being done as a string at times. So a strict match isn't going to complete, and thus false is being selected.

    The part that has been giving me trouble, is understanding why that string conversion is happening. I believe it is the separator: '', option. That isn't needed in this case, and when specified it will cause a join() to be performed, resulting in a string.

    Could you remove that option from your plug-ins checkbox fields and see how that goes?

    Allan

  • VolkhardVVolkhardV Posts: 20Questions: 5Answers: 0

    Hello Allen,
    thanks for your support.
    I was removing the separator-option on both fields. now i can´t check any checkbox - only uncheck the 1 box which is checked (see version online)

    You have an idea?

    Volkhard

  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin
    Answer ✓

    Hi Volkhard,

    Sorry about that - I'd forgotten that when there isn't a separator defined then the checkbox field type will return an array - which is causing the issue now.

    What to do is comment the separator option back in and add the following fields.getFormatter function for that field:

    getFormatter: function (val) {
      return val === 'true'
        ? true
        : false;
    }
    

    I believe that should now do it. The getFormatter will run just after the join is performed on the separator, allowing this to work.

    Allan

  • VolkhardVVolkhardV Posts: 20Questions: 5Answers: 0

    Hello Allan,
    this works - thanks !

    best regards
    Volkhard

Sign In or Register to comment.