Hi everybody,
I try to do the following in set_controls() of my custom class (that extends \Bricks\Element):
<?php
public function set_controls() {
//this is not working, cause $this->element['id'] is null at that point
$element_id = $this->element['id'];
$this->controls['tg_navInfo'] = [
'tab' => 'content',
'content' => 'My Id is: '.$element_id,
'type' => 'info',
];
}
?>
I cannot do that, because $this->element is null at that point.
I tried using a filter to change it later on, like this:
<?php
add_filter( 'bricks/element/settings', function( $settings, $element ) {
if ( $element->name === 'my_test_class' ) {
$element->controls['tg_navInfo']['content'] = 'Successfully edited by filter. Element id is '. $element['id'];
}
return $settings;
}, 10, 2 );
?>
But for it returns $settings and doesn’t apply the changes made to the element. So right now, I don’t know how to approach this in the best way. Can anybody help? Thank you!