title: How to remove a validator from a Select?
body: <p>I have a form where I need to add/remove validators dynamically. Based on a dropdown selection, other form fields may have different validation rules. </p>
  
  <p>For other kinds of inputs, I've used <code>replace(methodThatCreatesTheInput())</code> to get rid of a previously added validator. (Not knowing of a better way. Specifically, there doesn't seem to be any way to directly remove a validator from a component...)  </p>
  
  <p>With <strong><a href="http://wicket.apache.org/apidocs/1.4/org/apache/wicket/extensions/markup/html/form/select/Select.html" rel="nofollow noreferrer">Select</a></strong>, from wicket-extensions, this approach fails with something like: </p>
  
  <pre><code>WicketMessage: submitted http post value [[Ljava.lang.String;@5b4bf56d] 
  for SelectOption component  [8:myForm:targetInput] contains an 
  illegal relative path element [targetConsortiums:1:option] which does not
  point to an SelectOption component. Due to this the Select component cannot 
  resolve the selected SelectOption component pointed to by the illegal value.
  A possible reason is that component hierarchy changed between rendering and 
  form submission.
  </code></pre>
  
  <p>The method that creates the Select:</p>
  
  <pre><code>private FormComponent&lt;?&gt; targetSelection() {
      Map&lt;Class&lt;? extends Target&gt;, List&lt;Target&gt;&gt; targets = targetService.getAllAsMap();
  
      SelectOptions&lt;Target&gt; propertyOptions = new SelectOptions&lt;Target&gt;("targetConsortiums",
              targets.get(Consortium.class), new TargetRenderer());
      SelectOptions&lt;Target&gt; consortiumOptions = new SelectOptions&lt;Target&gt;("targetProperties",
              targets.get(Property.class), new TargetRenderer());
  
      Select select = new Select(ID_TARGET, new PropertyModel&lt;Target&gt;(model, "target"));
      select.add(propertyOptions);
      select.add(consortiumOptions);
      select.setRequired(true);
      select.setMarkupId(ID_TARGET);
  
      return select;
  }
  </code></pre>
  
  <p>(Why use a Select instead of normal DropDownChoice? We want the two types of choices to be clearly separated, <a href="https://stackoverflow.com/q/6592893/56285">as documented in this question</a>.) </p>
  
  <p><strong>Any ideas how to solve this?</strong> What I'm trying to achieve is, of course, very simple. Unfortunately Wicket disagrees, or I'm using it wrong.</p>
  
  <p>Wicket 1.4.</p>