2 Replies Latest reply on Jan 12, 2008 4:48 PM by (Andrew_Millne)

    Expanding on many-to-many

      Hi,

      I'm looking to expand on the functionality of the many to many wizard. Previously all of my applications have only required entities to have one feature so on a holiday rental site I used swimming pool, washing machine, parking etc. as "features" of the entity "property" and used the many to many wizard with a relational table to link them.

      I now wish to expand this principle to have "attributes" related to each feature.... so a property can have parking as a feature but this feature can also have "driveway", "garage", "Underground" etc as attributes
      I have four tables - property, features, feature_attributes and a table to link attributes to the property. Here is a quick DB schema to make things a bit easier to follow.

      Schema Mock-up

      So to add a feature/attribute to a property I add a row to the relational table linking the attribute to the property. I can do this manually using phpmyadmin with success and it works fine with the search/filtering part of the site that is already written, my problem is with designing the form and finding an ADDT solution to add the attribute relation rows.

      Can anybody point me in the right direction? My initial thinking is to use a nested repeat to loop through the features and display each attribute associated with it as either a checkbox group or radio group depending on whether the property can have multiple attributes for the individual feature or only one. How do I then make sure firstly the HTML is correct for the form and also add the ADDT part to do the insert/update

      Thanks

      - Andy
        • 1. Re: Expanding on many-to-many
          Level 1
          I think the solution is easier than I first thought. Would I be able to simply add the many-to-many wizard using the property table as master and attribute table as detail then alter the nested repeat code to first loop through features followed by attributes and make sure the INPUT elements have the correct id's prefixed with the mtm_?

          I have tried doing this but I get an error that says.

          "We could not add the new row. Please check the starter control or table."

          A google search on this error brings up nothing related.
          • 2. Re: Expanding on many-to-many
            Level 1
            I now have this working with the method from my previous post. I can only do this with checkboxes however as the name and id attributes for the INPUT tag need to be the same. take these two examples...

            First the checkboxes......

            <fieldset>
            <legend>Glazing</legend>
            <ol>
            <li>
            <input id="mtm_5" name="mtm_5" type="checkbox" value="1" />
            <label>Double</label>
            </li>
            <li>
            <input id="mtm_4" name="mtm_4" type="checkbox" value="1" />
            <label>Single</label>
            </li>
            <li>
            <input id="mtm_6" name="mtm_6" type="checkbox" value="1" />
            <label>Triple</label>
            </li>
            </ol>
            </fieldset>

            Now the radio buttons......

            <fieldset>
            <legend>Heating</legend>
            <ol>
            <li>
            <input id="mtm_2" name="heating" type="radio" value="1" />
            <label>Electric Fires</label>
            </li>
            <li>
            <input id="mtm_1" name="heating" type="radio" value="1" />
            <label>Gas Central</label>
            </li>
            <li>
            <input id="mtm_3" name="heating" type="radio" value="1" />
            <label>Oil Central</label>
            </li>
            </ol>
            </fieldset>

            In order to get radio group functionality I had to change the NAME to something that was the same for every option but then ADDT does not function correctly as it expects the NAME to be the detail table id prefixed with mtm.

            Any ideas?