Zoran Kalinić
Zoran Kalinić

Reputation: 317

Cakephp Radio input within table through foreach

I want radio button within table, without label and one radio button for one table row, while all grouped in one single group, so user can select single table row by selecting one radio button from the group ...

In pure html it looks like this:

<div class="radio">
    <label>
        <input type="radio" name="memberPaymentsRadio" value="mp<?php echo $key;?>" aria-label="...">
    </label>
</div>

What would be the code in cakephp to get the same html code?

I tried like this:

foreach($payments as $key => $payment){
    ...
    echo $form->input('memberPaymentsRadio',
        array(
            'div' => array('class' => 'radio'),
            'label' => false,
            'type' => 'radio',
            'aria-label' => '...',
            'options' => array('mp'.$key),
            'before' => '<label>',
            'after' => '</label>'
        )
    );
}

but I'm getting radio buttons, one per table row, and all within specific table column, but with labels 'mp0', 'mp1', which is not what I was looking for...

Upvotes: 2

Views: 784

Answers (1)

Prakash Saini
Prakash Saini

Reputation: 481

You can use like this

$this->Form->radio('memberPaymentsRadio', array('mp'.$key => ""),array('class' => 'radio', 'before' => '<label>','after' => '</label>','label' => false));

Upvotes: 0

Related Questions