code: public void actionToggleElement() {
  
          // get the necessary parameters to add/remove the element
          int index = 0;
          try {
              index = Integer.parseInt(getParamElementIndex());
          } catch (Exception e) {
              // ignore, should not happen
          }
          String name = getParamElementName();
          // get the base parameter definition
          CmsWidgetDialogParameter base = getParameterDefinition(name);
          if (base != null) {
              // the requested parameter is valid for this dialog
              List<CmsWidgetDialogParameter> params = getParameters().get(name);
              if (getAction() == ACTION_ELEMENT_REMOVE) {
                  // remove the value
                  params.remove(index);
              } else {
                  List<CmsWidgetDialogParameter> sequence = getParameters().get(base.getName());
                  if (sequence.size() > 0) {
                      // add the new value after the clicked element
                      index = index + 1;
                  }
                  CmsWidgetDialogParameter newParam = new CmsWidgetDialogParameter(base, index);
                  params.add(index, newParam);
              }
              // reset all index value in the parameter list
              for (int i = 0; i < params.size(); i++) {
                  CmsWidgetDialogParameter param = params.get(i);
                  param.setindex(i);
              }
          }
      }
docs: Adds or removes an optional element.<p>
  
  Depends on the value stored in the <code>{@link CmsDialog#getAction()}</code> method.<p>