cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robby Pelssers" <>
Subject RE: Radiobuttons in CForm Repeater
Date Wed, 25 Jul 2007 09:59:32 GMT
Hi Markus,


I don't think it is possible to accomplish this.  You could define a
Boolean-field as child of the repeater, but this means that only within
one repeaterrow, you will have a radiobutton.


I think you could accomplish the behaviour you want by doing something
like this:


<fd:form xmlns:fd="">


    <fd:repeater id="products">


        <fd:booleanfield id="isSelected">

          <fd:datatype base="boolean"/>



d(event, viewData);    




           // OTHER WIDGETS







Your javascript controller would look similar to:


Function ShoppingCart() {

    this.form = new Form("context://??/??/shoppingcart.fd");

    this.form.setAttribute("controller", this);



ShoppingCart.prototype.handleIsSelectedValueChanged = function(event,
viewData) {

    Var productsRepeater = this.form.form.lookupWidget("products");

    Var isSelected = event.source.getValue().booleanValue();

    //only in case isSelected == true we need to deselect any other
selected product

    if (isSelected) {

        var rowIndex = productsRepeater.indexOf(event.source.parent);

        for (var i = 0; i < productsRepeater.getSize(); i++) {

            var row = productsRepeater.getRow(i);

            //we only need to set the values of the other rows to false

            if (i != rowIndex) {








Hope this helps,



Robby Pelssers






Van: Markus Kratz [] 
Verzonden: woensdag, juli 2007 11:31
Onderwerp: Radiobuttons in CForm Repeater



I need a radio button for each item in a CForms repeater, so that the
user of this form can select only one item as default.  The repeater is
used, because there are also other needed widgets in the rows.

When I use a boolean-field with the styling "radio" inside the repeater,
it is transformed to checkboxes with different names. So even if it
would be transformed to radiobuttons, it wouldn't work like I suspected.

When I use a selection-list inside the repeater, there is a
selection-list for each row in the repeater. Also not what I expect.

I only have an idea for a workaround, which doesn't satisfy me. So does
anybody know how to solve this problem? 

Best regards,
Markus Kratz

View raw message