Hey all, brand new to Cake but I'm loving it so far.  I ran into a
hitch trying to save some form data, and was wondering if anybody could
help me figure out what the problem is.  Two values, both the result of
select boxes, are being changed when the form is submitted.  The values
are correct in $this->data, but when i $this->Project->save, it changes
only these two values.  I'm running cake 1.1.6.3264, php 5.1.4, mysql
5.0.21-standard

The relevant parts of the controller (which is otherwise pretty much
straight from bake.php):

echo "<pre>"; print_r($this->data);

                        if($this->Project->save($this->data))
                        {
die(print_r($this->data));


The relevant parts of the View:

<?php echo $html->selectTag('Project/project_status', $statuses,
$projects['Project']['project_status']); ?>

and

<?= $html->selectTag('Project/project_priority', $priorities,
$projects['Project']['project_priority']); ?>


The relevant parts of the outputted page:

<select name="data[Project][project_priority]"
id="ProjectProjectPriority">
<option value="" >&nbsp;</option>
<option value="1"  selected="selected">None</option>
<option value="3" >Low</option>
<option value="5" >Medium</option>
<option value="7" >High</option>
<option value="9" >Urgent</option>
</select>

and

<select name="data[Project][project_status]"
id="ProjectProjectStatus">
<option value="" >&nbsp;</option>
<option value="1"  selected="selected">In Process</option>
<option value="3" >Planning</option>
<option value="6" >Proposed</option>
<option value="7" >Deferred</option>
<option value="8" >Completed</option>
<option value="9" >Trashcan</option>
</select>


i print_r'd the data array before and afer saving... you can see in the
output that the data doesn't change, and is correct:

Array
(
    [Project] => Array
        (
            [id] => 1
            [project_name] => test project 1
            [project_priority] => 7
            [project_assigned] => someone
            [project_status] => 7
            [project_hidedash] => 1
            [project_color] => 666699
            [project_notes] => a few notes
            [project_due] => 1946-01-01
        )

)
Array
(
    [Project] => Array
        (
            [id] => 1
            [project_name] => test project 1
            [project_priority] => 7
            [project_assigned] => someone
            [project_status] => 7
            [project_hidedash] => 1
            [project_color] => 666699
            [project_notes] => a few notes
            [project_due] => 1946-01-01
        )

)

but this is the resulting query:

UPDATE `projects` SET `id` = '1',`project_name` = 'test project
1',`project_priority` = '1',`project_assigned` =
'someone',`project_status` = '1',`project_hidedash` =
'1',`project_color` = '666699',`project_notes` = 'a few
notes',`project_due` = '1946-01-01' WHERE `id` = '1'

table structure:

CREATE TABLE projects (
  id int(11) NOT NULL auto_increment,
  project_name varchar(64) NOT NULL default '',
  project_assigned varchar(32) NOT NULL,
  project_due date NOT NULL default '0000-00-00',
  project_priority tinyint(1) NOT NULL default '0',
  project_status tinyint(1) NOT NULL default '0',
  project_color char(13) NOT NULL,
  project_hidedash enum('0','1') NOT NULL default '0',
  project_notes text NOT NULL,
  project_owner int(10) NOT NULL default '0',
  PRIMARY KEY  (id),
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


note that project_priority and project_status are both set to 7 in the
data but are being saved as 1.  there is no validation on the data (i
tried setting the validation to

my only guess is that mysql is trying to save a string into an int
field and setting it to 1 instead of casting it to an int, but i don't
know how to check that

any ideas?  thanks all


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to