I am trying to get the value of a field from a freeform event. Specifically I'm trying to see if a particular checkbox is in a form submission.
craft()->on(
"freeform_submissions.onBeforeSave",
function (Event $event) {
$submission = $event->params["model"];
$field = $submission['fieldMetadata']['checkbox_handle'];
This works to this point. I see if I do Craft:dd($field);
I have a checkboxField object. But from here on I can't get any info about that field.
$id = $field->id; // or:
$handle = $field->handle; // and any other properties
This throws: Fatal error: Cannot access protected property Solspace\Freeform\Library\Composer\Components\Fields\CheckboxField::$id
.
If I try:
$id = $field['id'];
I get: Fatal error: Cannot use object of type Solspace\Freeform\Library\Composer\Components\Fields\CheckboxField as array
The properties and methods are listed at: https://solspace.com/craft/freeform/docs/field/, but I can't access the properties. I can call the render()
method which works and that outputs html. I'm sure its something obvious, but I'm missing it.