This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I am using the builder plugin form and I simply want to get the value from field a and update field b +1
eg a=1, b=2 (a+1)
I have tried defaultFrom, trigger but I just can't get it to work. What am I missing?
Thanks
Figured it out myself, sort of.
I don't think you can do it with the builder form but if you edit the model php file
you can do it using the beforeCreate function
public function beforeCreate() { $this->b = $this->a+1; }
Hope this helps someone
Last updated
That is correct. The builder is only useful to quickly and nice build the models. Anything application specific like your code here would require you to edit the model file manually.
Be aware of the beforeCreate()
method though. It will be run once and only once when the model is being created. It will not run whenever it is being updated. Here beforeSave()
would be smarter - depending on the meaning of your model's property $b
1-4 of 4