You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Mark Lundquist <ml...@wrinkledog.com> on 2006/11/20 17:45:45 UTC

[CForms] add requiredness using inheritance... how to?

Hi,

This is a question about CForms libraries and widget inheritance... any 
help is gratefully appreciated!

I have a series of forms implementing an application transaction.  Two 
variants of the transaction use different versions of one of the forms, 
but the two versions of the form must share a few fields.  The widget 
definitions are non-trivial enough (selection lists and an AJAX 
on-value-changed handler) that I don't want to just duplicate them; I 
really want to be able to factor them into a common library.

So, I have this library definition:

	<fd:group id="geography">
		<fd:field id="country">
			<!-- blah blah blah -->
		</fd:field>
		<fd:field id="state">
			<!-- blah blah blah -->
		</fd:field>
		<fd:field id="zip">
			<!-- blah blah blah -->
		</fd:field>
	</fd:group>

and this works great with <fb:import> and <fd:expand> in the forms that 
need these widgets.  Now, here's the catch: I realized that in one 
version of the form, these are required field, while in the other they 
are not.  I tried to add requiredness by using the following construct 
instead of <fd:expand>:

     <fd:group id="geography" extends="geo:geography">
       <fd:field id="country" required="true"/>
       <fd:field id="state" required="true"/>
       <fd:field id="zip" required="true"/>
     </group>

...but it doesn't work.  The form still works fine, it's just that 
these widgets are still non-required.

Is what I'm trying to do not possible?  Or am  I just coding it wrong?

Thanks,
—ml—