Kamal Bhatt pisze:
> Hi,
> I have a requirement to dynamically allocate the help and labels for
> fields in a repeater. My solution, uses jx templates to set fi:help and
> fi:label, like so:
>
> <ft:repeater-widget id="style_flds">
> <ft:widget id="value">
> <fi:label>
> <jx:out
> value="${form.getChild('styles').getRow(style_idx).getChild('style_flds').getRow(repeaterLoop.index).getChild('label').value}"
> />
> </fi:label>
> <fi:styling
> type="${form.getChild('styles').getRow(style_idx).getChild('style_flds').getRow(repeaterLoop.index).getChild('fld_type').value}"
> />
> <fi:help>
> <jx:out
> value="${form.getChild('styles').getRow(style_idx).getChild('style_flds').getRow(repeaterLoop.index).getChild('help').value}"
> />
> </fi:help>
> </ft:widget>
> </ft:repeater-widget>
>
> This is a hack. Normally I would be fine with this, but as you can
> probably guess we are using 2.1.7 CForms. My question is, if we upgrade
> and get all ajaxy, what is the likelihood my hack will continue to work?
I don't think so it is going to work without minor adjustments. You will need
to wrap fi:* you are
generating manually with bu:replace tags according to a widget value change.
You just need to add
construct like:
<jx:if test="form.updatedWidgetIds.contains('label')">
<bu:replace>
<fi:label>
<jx:out
value="${form.getChild('styles').getRow(style_idx).getChild('style_flds').getRow(repeaterLoop.index).getChild('label').value}"/>
</fi:label>
</bu:replace>
</jx:if>
It must be done that way so update of label is performed only if widget that
label value relies on
was changed. Construct shown above will work in non-AJAX mode, also.
I must admit I was typing from my head so there may be some minor details
missing.
> Another question, for the development team, has anyone thought about being
> able to dynamically set labels in the definition? It seems like a rather
> onerous assumption that ever field in a repeater will be labelled the same
> way. What would be nice would be able to set state, label and headings in
> the definition (where it belongs) using javascript. For example:
>
> <fd:field id="value">
> <fd:datatype base="string" />
> <fd:state>
> <fd:javascript>
> if (blah) return(WidgetState.ACTIVE);
> else return(WidgetState.INVISIBLE);
> </fd:javascript>
> <fd:state>
> <fd:label>
> <fd:javascript>
> if (blah) return("First label");
> else return("Second label");
> </fd:javascript>
> </fd:label>
> </fd:field>
>
> Anyway, my two cents.
Yep, it has been discussed a long time ago. I found a good response from
Sylvain on this topic:
http://article.gmane.org/gmane.text.xml.cocoon.devel/35520
Reading from that, your solution is not a hack really. You only need to adopt
it to AJAX techniques.
I hope that helps you a bit.
--
Grzegorz Kossakowski
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]