Jeffrey L. Roberts
Jeffrey L. Roberts

Reputation: 2994

CakePHP 3.x Change Label For Radio Buttons

I am attempting to create several radio buttons with a specific label...

I am using the following code, however, there is no label

echo $this->Form->radio('qualify', [['value' => 1, 'text' => 'Yes'], ['value' => 0, 'text' => 'No']], ['label' => 'Qualify Only']);

Any ideas on how I can get the label to show up for these radio buttons?

Upvotes: 0

Views: 545

Answers (2)

Omebe Johnbosco
Omebe Johnbosco

Reputation: 56

<?php 
 $qualify = [['value'=>'0','text'=>'No'],['value'=>'1','text'=>'Yes']]; 

 echo $this->Form->input('qualify', array(
                      'options' => $qualify,
                      'type' => 'radio',
                     'placeholder' => 'Qualify Only'
                      ));
?>

This code will be able to pick any existing value in the edit view.

Upvotes: 2

distromob
distromob

Reputation: 354

You can still use the $this->Form->input and put a type whether its a select or radio

<?php 
     $qualify = ['0' => 'No', '1' => 'Yes']; 

     echo $this->Form->input('qualify', array(
                          'options' => $qualify,
                          'type' => 'radio',
                         'placeholder' => 'Qualify Only'
                          ));
 ?>

Upvotes: 1

Related Questions