Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7958121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:22:19+00:00 2026-06-04T04:22:19+00:00

I’m trying to get a better setup working for updating a model with nested

  • 0

I’m trying to get a better setup working for updating a model with nested properties.

Right now in my edit view I define the textFieldTag manually to create the params struct by setting up the name as "myModel[myNestedProperty][#modelID#,#key2id#][name]"

in update action…

if I just use myModel.update(params.myModel) I can’t get the update to work if there are any elements that require deletion

so I destroy all the models of the nested property that have the same id as myModel, in which case it works.

The downside is that if the update fails, the nested properties are all gone.

I’ve tried grabbing all of the models first before deleting them and .saveing them, but for some reason that’s not working.

Looks like cfwheel is setup for this kind of relation with the checkboxes, but I need it to work with textfield and select items in my form.


Update

I realized I have another issue. Essentially I would like to expand on this to be able to use it across multiple nested properties and relationships.

the issue is in the way I setup the name especially for select dropdowns:

name="myModel[myNestedProperty][#modelID#, ][nestedID]"

the issue is that the second id cannot be declared, because it will be assigned as the id rather than using the value that I select.

To be honest, this is the one issue I’ve been battling with my whole time. I’m dealing with it by regenerating the models in the controller, I just forgot I haven’t solved that issue yet.

Is there a way I can have these values not be used at all, and have them populated from the structure dynamically?

let’s say I have (truncated) a name tcat[34,0][catID] or tcat[34,][catID], (where the catID should be the 2nd ID).

the params’ tcat structure that gets generated is

[34,0]{catID = 12,14,18}

or

[34,]{catID = 12,14,18}

I’d like the params’ tcat structure to have multiple structs like:

[34,12]{tID = 34; catID = 12}
[34,14]{tID = 34; catID = 14}
[34,18]{tID = 34; catID = 18}

Is there a way around this?

I’m working with a lot of composite key nested properties, and if I could have this part alone working it would make it a lot easier. I know one way is to update the name with javascript, but I think that would be the (very,very) last resort.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:22:20+00:00Added an answer on June 4, 2026 at 4:22 am

    Can you give this a try?

    Set up a callback in the parent model that checks to see if name is blank and flags for deletion if it’s blank.

    <cffunction name="init">
        ...
    
        <!--- This could also be `beforeValidation` if you want to make `name` required for the child model --->
        <cfset beforeSave("$provisionMyNestedProperty")>
    </cffunction>
    
    <cffunction name="$provisionMyNestedProperty">
        <cfscript>
            if (StructKeyExists(this, "myNestedProperty") && IsArray(this.myNestedProperty))
            {
                for (local.i = 1; local.i <= ArrayLen(this.myNestedProperty); local.i++)
                {
                    if (!StructKeyExists(this.myNestedProperty[local.i], "name") || !Len(Trim(this.myNestedProperty[local.i].name)))
                        this.myNestedProperty[local.i]._delete = true;
                }
            }
        </cfscript>
    </cffunction>
    

    I’ll keep editing my answer until we can bang out a solution. Hopefully that gives you a good start though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.