Jump to content

Recommended Posts

$options = array_flip(Set::extract('/QuestionnairePossibleAnswer/id', $question));

debug($options);

echo $form->input(

'QuestionnaireQuestionnaire.QuestionnaireAnswer.'.$count.'.possible_answer_id',

array(

'type' => 'radio',

'options' => $options,

'label' => false,

'legend' => false,

'before' => '<td class="radio">',

'after' => '</td>',

'separator' => '</td><td class="radio">',

'hiddenField' => false

)

);

 

$options =

Array

(

    [4ba8ab7d-9450-45e0-867e-1d7893974a26] => 0

    [4ba8ab92-ce20-443e-a23c-1d7893974a26] => 1

    [4ba8ab99-3684-4557-ae1e-151093974a26] => 2

    [4ba8aba1-6254-40be-932b-1d7893974a26] => 3

    [4ba8abab-b4bc-4209-9001-1d7893974a26] => 4

    [4ba8abb2-4f64-49d8-8735-1d7893974a26] => 5

)

 

Why when I view this do I get the 5 radio buttons with the numbers 0 -> 5 next to them as if they are labels???

 

<input type="radio" value="4ba8ab7d-9450-45e0-867e-1d7893974a26" id="QuestionnaireQuestionnaireQuestionnaireAnswer0PossibleAnswerId4ba8ab7d-9450-45e0-867e-1d7893974a26" name="data[QuestionnaireQuestionnaire][QuestionnaireAnswer][0][possible_answer_id]">0

 

Link to comment
https://forums.phpfreaks.com/topic/199138-cakephp-form-input/
Share on other sites

Well, what does your array originally look like ( Set::extract('/QuestionnairePossibleAnswer/id', $question) )?

 

If it looks like

array('test', 'test2') then it makes a lot of sense because array_flip swaps the key/value. So it would become array('test'=>0, 'test2'=>1)

Link to comment
https://forums.phpfreaks.com/topic/199138-cakephp-form-input/#findComment-1047200
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.