Login

    Register

Managed Hosting

PROJECT CATEGORIES

 

Form Utilities CFC
Project Home Blog Forums Wiki Known Issues Contact Project

Form Utilities CFC Issue: append to array instead of setting at index

Name: append to array instead of setting at index
ID: 5
Project: Form Utilities CFC
Type: Enhancement
Area: Code
Severity: Normal
Status: Closed
Related URL:
Creator: Seth Feldkamp
Created: 04/26/10 11:54 AM
Updated: 04/26/10 4:08 PM
Description: I think the array should be sized dynamically instead of inserting at the index parsed from the field name. Perhaps there should be a parameter to control this for backwards compatibility.

example: a source struct contains these fields:
field[1]
field[3]

you will end up with a 3 element array and the second element is undefined. I would prefer a way to get a two element array instead.

use case:
the above scenario occurs when I allow a user to disable form fields named with array notation since disable fields are not submitted.

there are a number of ways to work around this, but i think it would be nice if this were an option within FormUtilities.
History: Created by sfeldkamp (Seth Feldkamp) : 04/26/10 11:54 AM

Comment by brian428 (Brian Kotek) : 04/26/10 1:17 PM
Hi Seth, thanks for the feedback! However, I don't plan to try and implement this. Since the whole point of the utility is to translate the form fields to corresponding CF data structures, I'd be very leery of something altering that translation. If someone has a use case like this, I'd say it would be up to them to handle it. Given how easy it is to simply update the field names using JavaScript, or to check the array elements using ArrayIsDefined, those are the routes I would take. I'd much rather see explicit code to show what is being done to handle this specific use case than to have the CFC "magically" alter the translation and hope another developer knows where to look to figure out what is happening. Hopefully that explains my position? Thanks.

Updated by brian428 (Brian Kotek) : 04/26/10 1:17 PM

Comment by sfeldkamp (Seth Feldkamp) : 04/26/10 4:08 PM
Thanks for the comment Brian, I agree with your assessment. I found that using a numbered struct notation "item.#index#.field" is the best workaround (for my use).

Dynamically sizing the array would depend too much on position of the field in the form struct.

To add a comment to this bug, please login using the link above.