I am setting attributes on my record using a models' attributes (that has validated successfully). I cannot figure out why the values aren't assigned. I can manually assign each one but that's redundant.
// Set attributes
// Massive assignment will only be made for fields which have passed some explicit validation rule.
if ($model->validate())
{
$purchaseRecord->setAttributes($model->getAttributes());
var_dump($model->snipInvoiceNumber); // works
var_dump($purchaseRecord->snipInvoiceNumber); // null value
$purchaseRecord->snipInvoiceNumber = $model->snipInvoiceNumber; // works
}
UPDATE: Per comments on this thread I looped through and set the attributes individually. Anyone have insight on why setAttributes didn't work? Save contact form data to database
This is what I used instead of setAttributes (plural).
foreach ($model->getAttributes() as $key => $value ) {
$purchaseRecord->setAttribute($key, $value);
}