I have a form and after submission, I can view the form values using: var_dump($this->form->getValues();
. One of my form values (from a multi-select widget) is this:
["cat_list"]=>
array(1) {
[0]=>
string(1) "1"
}
I wish to append a value to this array before saving the form. How do I do this? I thought I can do this:
$values = $this->form->getValues();
array_push($values['cat_list'], '99'); // <--- 99 is the number I want to append
$this->form->setCatList($values['cat_list']);
$this->form->save();
But that doesn't work:
Call to undefined method FrontendOfferForm::setCatList.
Any clues?
$values['cat_list']
after you callarray_push()
? – MattsetCatList()
method that isn't working. It's not the correct method. I don't know what to call or how to set the value in the form at this point. – Jake Wilsonarray_push
works as expected but when you call$this->form->save()
the underlying object will updated with the original$values
array by the form. – 1edsetCatList()
to update the form values without success. Also, 99 is just an arbitrary number I picked for the above example. It could be essentially anything that I need to add to that array. – Jake Wilson