cake_1.2.0.6311-beta, PHP 5.2.4 I have a few survey scripts I'm attempting to move to Cake and am well and truly in the deep end now. The existing scripts do not rely on a database, as the client is not interested in saving the data, just having it sent somewhere. There are only 3 surveys and there likely won't be many more so i won't insist.
Anyhoo, my problem is that i'm stuck just trying to set up the model and view. I found this post by Mariano that suggests how to deal with this but there's little explanation of how to go about using the change. https://trac.cakephp.org/ticket/2241 I've included the schema() method in my model along with the following: var $fields = array( 'q1' => 'string', 'q2a' => 'integer', 'q2b' => 'string', 'q3a' => 'integer', 'q3b' => 'string', 'q4a' => 'string', 'q4b' => 'string', 'q5' => 'string', 'q6' => 'string', 'q7a' => 'integer', 'q7b' => 'string' ); If i dump a call to schema() i can see that it does return a Set. But if i place a $form->input() in my view i get the following error: Fatal error: Cannot use object of type Set as array in /usr/local/cake_1.2.0.6311-beta/cake/libs/view/helpers/form.php on line 504 The problem line is: } elseif (isset($this->fieldset['fields'][$this->field()])) { If i change it (just for fun) to: } elseif (is_array($this->fieldset['fields']) && isset($this- >fieldset['fields'][$this->field()])) { it passes ok but i then get the same error triggered in Model::getColumnType(). So, Mariano, if you're reading: how can i create an input tag? I have no problem with writing it manually, but if that's the case, how do i name it? I also have no compunctions about patching the libs but i don't want to start doing so willy-nilly. I've been threading through the API in an attempt to resolve this but there's tons that i'm still not clear on. Additionally, the survey consists of a mix of text fields and checkboxes. I've set the types for those in $fields to 'integer' but i have a feeling that's not appropriate at all. That is, the response to, eg. q2 can be an array of integers. I'm not sure how to set that up in $fields. Last part, to give a complete picture of where i'm at: I'm using the very helpful HabtmHelper as posted here: http://bakery.cakephp.org/articles/view/create-multiple-checkboxes-instead-of-a-multiple-select-in-your-views So, in addition to the $fields array above, the model also has an array like so: var $options = array( 'q2' => array( '1' => 'a checkbox label', '2' => 'another checkbox label', ... ), 'q3' => array( '1' => 'another one', '2' => 'again', ... ), 'q7' => array( '1' => 'and again', ... ) ); Where q2, q3, and q7 are the questions which have a set of checkboxes for the response. The controller then has this in index(): $this->set('q2_options', $this->MaapMusicSurvey->options['q2']); $this->set('q2_selected', array()); $this->set('q3_options', $this->MaapMusicSurvey->options['q3']); $this->set('q3_selected', array()); $this->set('q7_options', $this->MaapMusicSurvey->options['q7']); $this->set('q7_selected', array()); Finally, the checkboxes are created in the view like so: $habtm->checkboxMultiple('MaapMusicSurvey/MaapMusicSurvey', $q2_options, $q2_selected, null, array('class' => 'checkbox'), array('class' => 'checkboxMultiple'), true, true) While this appears to work (and well, i might add) i'm not absolutely sure that i'm going about this correctly. Until i get over the schema()/Set hump i'm really not sure i'm going in the correct direction here. Any pointers are more than welcome. Sorry or the long post but there's a lot here to explain. b --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
