code: protected void removeEmptyResourceFields() {
  
          Set<Component> componentsToRemove = new HashSet<Component>();
          int count = 0;
          Component lastElement = null;
  
          for (Component c : m_resources) {
              if (c instanceof CmsRemovableFormRow<?>) {
                  count++;
                  AbstractField<?> field = (AbstractField<?>)((CmsRemovableFormRow)c).getInput();
                  String value = (String)(field.getValue());
                  if (value.isEmpty()) {
                      componentsToRemove.add(c);
                      lastElement = c;
                  }
              }
          }
  
          //if all fields are empty -> keep one of them to attach validator to
          if (componentsToRemove.size() == count) {
              componentsToRemove.remove(lastElement);
          }
  
          if (count == 0) {
              addResource("");
          }
  
          for (Component c : componentsToRemove) {
              m_resources.removeComponent(c);
              m_componentsToValidate.remove(c);
          }
      }
docs: Removes empty resource fields.<p>