score:-1

it looks like the only difference you are talking about making is using an array of objects instead of strings? if that's the case, when looping through the array to create the checkboxes, you access the object attributes using dot notation. it should look something like this if i understand the problem correctly.

from checkboxgroup component:

this.props.options.foreach(el => {
  let name = el.name;
  let id = el.id;

  //rest of code to create checkboxes

  or to show an example in creating components

  let checkboxmarkup = [];
  checkboxmarkup.push(
    <input type="checkbox" id={el.id} name={el.name} key={`${el.id} - ${el.name}`}/>
  );
}

'el' in this case refers to each individual object when looping through the array. it's not necessary to assign it to a variable, i just used that to show an example of how to access the properties.

score:0

problem solved. i should use "use with grid" type of group checkbox. it accepts object array. the only think i could do was creating a function that inject "label" and "value" to my object. it makes some duplicates but no problem.

function groupecheckboxify(obj, labelfrom) {
    for (var i = 0; i < obj.length; i++) {
      if (obj[i][labelfrom]) {
        obj[i]['label'] = obj[i][labelfrom];
        obj[i]['value'] = obj[i][labelfrom];
      }
      if (i == obj.length - 1) {
        return obj;
      }
    }
}

// for calling it:
groupecheckboxify( myobject , 'name');

Related Query

More Query from same tag