Search code examples
google-app-maker

How to hide the null item option in appmaker radio group when allowNull=true and field is boolean?


I have a boolean field for which I am using a radio group for which allowNull=true and no default value has been set. It currently looks like the below

enter image description here

I want the same to look like below (as I don't want to show the null option)

enter image description here

Note: Want to achieve this without changing the allowNull value and also without setting default value to true or false.


Solution

  • Adding the following to the onAttach event handler did the trick for me:

    setTimeout(function(){
      var elem = widget.getElement();
      var children = elem.children[1];
      var grandChildren = children.children;
      var grandChild = grandChildren[0];
      grandChild.parentNode.removeChild(grandChild);
    },100);