Wednesday, December 3, 2008

Re: HABTM fields type not detected in RC3

Hello,

can someone please help me on this matter ?

The data is retreived with :

$this->User->id = $id;

$params = array(
'contain' => array(
'Company',
'Skill'
)
);

$this->data = $this->User->find('first', $params);

And $this->data has this structure :

Array
(
[User] => Array
(
[id] => 1
...
)
[Company] => Array
(
[0] => Array
(
[id] => 36
[company_type_id] => 0
[slug] => test
[name] => test
[created] => 0000-00-00 00:00:00
[modified] => 0000-00-00 00:00:00
[address] =>
[zip] =>
[town] =>
[state_id] => 0
[country_id] =>
[phone] =>
[website] =>
[email] =>
[banner] =>
[description] =>
[path] =>
[manager] =>
[views] => 0
[UsersCompany] => Array
(
[id] => 115
[user_id] => 1
[company_id] => 36
[is_school] => 0
[description] => test position
[start_date] => 2005-08-01
[end_date] => 2008-02-29
[current] => 0
)

)
...


All I can do now is leave the input text fields for the dates if I
want them to be saved properly.

Can this be filed as a bug if it's written properly ?

Regards,

Jérôme

PS : 'CvsController' is a controller I designed to manipulate CVs and
uses both 'User' and 'Company' model. I retreive the data with :

On 23 nov, 12:14, Jne <goo...@neuveglise.net> wrote:
> Hi,
>
> I have a CV controller that Uses two models : Users and Companies
> Users HABTM Companies with a join table with :
> id (int)
> user_id (int)
> company_id (int)
> start_date (date)
> end_date (date)
> description (text)
> current(boolean)
>
> when retreiving data in my view :
>                         <?php $i = 0; ?>
>                         <?php echo $form->create('Cv', array('action' => 'edit'));?>
>                         <?php echo $form->input('User.id', array('type' => 'hidden'));         ?>
>                                 <?php        echo $form->input('Company.'.$i.'.UsersCompany.is_school',
> array('type' => 'select', 'options' => array('1' => 'School', '0' =>
> 'Work'), 'empty' => 'Type of experience ?')); ?>
>                                 <div class="input text">
>                                         <label for="<?php echo 'Company'.$i.'Name' ?>"><?php echo __
> ('School name'); ?></label>
>                                         <?php echo $ajax->autoComplete('Company.'.$i.'.name', '/cvs/
> companyComplete/'.$i); ?>
>                                 </div>
>                                         <?php echo $form->input('Company.'.
> $i.'.UsersCompany.description');
>                                         echo $form->input('Company.'.$i.'.UsersCompany.start_date');
>                                         echo $form->input('Company.'.$i.'.UsersCompany.end_date', array
> ('type' => 'date', 'dateFormat' => 'MY', 'minYear' => date('Y') - 90 ,
> 'maxYear' => date('Y') + 5, 'empty' => true));
>                                         echo $form->input('Company.'.$i.'.UsersCompany.current', array
> ('type' => 'checkbox'));
>
> On the first 'start_date' field, the fields is a input/text one (with
> proper value populated)
> The second one is also OK in the browser but the select fields name
> are incorrect) as it produces the following HTML :
>
> <label for="Company0UsersCompanyEndDateMonth">End Date</label><select
> name="data[Cv]" id="Cv">...
>
> where it should be :
>
> <label for="Company0UsersCompanyEndDateMonth">End Date</label><select
> name="data[Company][0][UsersCompany][EndDate][Month]" id="Cv">
>
> Am I missing something ?
>
> Thanks !
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: