Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
I have a table as shown in the image below:
radio_table.png
radio_table.png (23.93 KiB) Viewed 1716 times


As can be seen, the table has a radio button in the beginning. Now the purpose is to be able to select requirements of 1000kgs, 2000kgs etc. Only one of the four options (currently) can be selected.

My issue is I am unable to get the radio buttons in a single bound editable of type radio. How do I go about with it?

Is it possible to use a single <cms:editable type="radio"/> to do this? If not how can it be done? Currently all values are hard coded.

How to go about?

Regards,
Aashish
Image
where innovation meets technology
Anyone any inputs on this?
Image
where innovation meets technology
Hopefully the following sample gives you some ideas.

Code: Select all
<?php require_once("../../cms/cms.php"); ?>
<cms:template clonable='1' title='RadioTable' hidden='0'>
    <cms:editable type='radio' name='radio' opt_values='1000 kgs=1000|2000 kgs=2000|3000 kgs=3000|4000 kgs=4000' />
</cms:template>


    <cms:if "<cms:not k_is_page />">
        <cms:pages masterpage=k_template_name limit='1'>
            <cms:redirect k_page_link />
        </cms:pages>
    </cms:if>

    <cms:set radio_editable = 'radio' scope='global' />


    <cms:db_fields masterpage=k_template_name page_name=k_page_name names=radio_editable >
        <cms:set my_values = '' scope='global' />
        <cms:each opt_values sep='|'>
            <cms:each item sep='='>
                <cms:if k_last_item >
                    <cms:set my_values = "<cms:concat my_values item />" scope='global' />
                </cms:if>
            </cms:each>
            <cms:if k_last_item='0'><cms:set my_values = "<cms:concat my_values '|' />" scope='global' /></cms:if>
        </cms:each>
    </cms:db_fields>

    <cms:form
        masterpage=k_template_name
        mode='edit'
        page_id=k_page_id
        enctype='multipart/form-data'
        method='post'
        anchor='0'
        >

        <cms:if k_error >
            <div class="error">
                <cms:each k_error >
                    <br><cms:show item />
                </cms:each>
            </div>
        </cms:if>

        <table border="1">
            <tbody>
                <cms:each my_values sep='|' as='value'>
                <cms:if value>
                <tr>
                    <td>
                        <input type="radio" name="<cms:concat 'f_' radio_editable />" value="<cms:show value />">
                    </td>
                </tr>
                </cms:if>
                </cms:each>
            </tbody>
        </table>

        <br />
        <cms:hide>
            <cms:input type='bound' name='radio' />
        </cms:hide>

        <button type="submit">Submit</button>


        <cms:if k_success >

            <cms:dump />

        </cms:if>
    </cms:form>
<?php COUCH::invoke(); ?>

@trendoman
I am yet to give it a try. Will do so and get back to you!
Regards,
GenXCoders
Image
where innovation meets technology
4 posts Page 1 of 1