After struggling with this for nearly 2 weeks I've managed to get it
working. Oh boy! The pain I've been through trying to sort this out;
but I'm so chuffed I got it sorted without anyone responding to the
(several) postings I've made on this topic. I'll try to put a blog
posting together on this for the benefit of anyone following.
On Jul 28, 4:52 pm, DavidH <DJHollingwo...@gmail.com> wrote:
> Hi
>
> I'm hoping someone will be able to put me out of my misery with thisHABTMproblem I have because it's doing my head in.
>
> I have an application to draw charts of key performance Indicators
> (KPIs). A chart can have many KPIs and a KPI can appear on many
> charts. So I have models:
>
> Chart
> Kpi
>
> and aHABTMrelationship between them using a join table called
> charts_kpis. This all worked like a dream. I had a form that allowed
> the user to specify their chart details (title, size etc) and select
> which KPIs to display on the chart using checkboxes to select the
> KPIs. It was cool!
>
> The I started to add some additional attributes. For example a KPI can
> be displayed in a different colour on each chart and the lines/bar can
> be a different width. So I added some attributes to my charts_kpis
> table which now has the structure:
>
> id - PK
> kpi_id - references kpis table
> chart_id - references charts table
> kpi_colour_id - references kpi_colours table. A model exists for this
> and defines a hasMany relationship with charts_kpis table
> width - width to display this KPI on this chart
>
> Here I started to run into problems. In the end I dissolved theHABTM
> relationship between charts and kpis and resorted to:
>
> Chart hasMany ChartsKpi
> ChartsKpi belongsTo Chart
> Kpi hasMany ChartsKpi
> ChartsKpi belongsTo Kpi
>
> and, of course
>
> KpiColour hasMany ChartsKpi
> ChartsKpi belongsTo KpiColour
>
> However the lengths I've had to go to to get the add/edit forms to
> work (well, the edit form still isn't working right) leads me to think
> that I've really gone about this the wrong way. What I want is a form
> that allows the user to add/edit the chart details (in the charts
> table) at the top and below this to select the KPIs that they want
> (using a checkbox) and select the colour and set the width for the
> KPIs they've selected. (This is very difficult to describe without a
> picture). There's many more attributes to follow once I have this
> 'simple' case working.
>
> Should I have been able to do this using the originalHABTM
> relationship?
>
> Thanks in advance
>
> David
--~--~---------~--~----~------------~-------~--~----~
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:
Post a Comment