Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

How to save array of field like name[]?

edited April 21 in Modules

I am trying to save some values to a model where I will have mutiple values of same field. Is there an easy way besides converting my field values to record level objects and saving them individually in a loop? Being redundant is not so cool!

Comments

  • implode() and explode() a comma separated string?

  • No, I want to know if fuel has anything that turns array data to record object?

  • I don't think that serializing is what I need, as I have a form with fields say field1, field2, feild3, and they could be multiple in an array like field1[0, 1, 2], for each of them, I want to know if I can convert these fields of array into record object like object[field1[0], field2[1], field3[2]]. Am I making sense?
    I already have the model class setup so just want to know if fuel provides such a way to convert them automatically as opposed to I'm doing right now by placing them in loop?

  • If you are wanting to automatically create associated records, then you'll need to do it on an on_after_save hook on your model.

Sign In or Register to comment.