Adds custom control elements

Hello!
Could you help me a bit with something I’m struggle with… I’m trying to add custom controls to elements like Text widget based on this following code (I put this on the functions.php file) :

add_filter( 'bricks/elements/text/controls', function( $controls ) {
  $controls['myCustomElement'] = [
    'tab' => 'content',
    'label' => esc_html__( 'MY CUSTOM CHECKBOX', 'bricks' ),
    'type' => 'checkbox',
    'inline' => true,
    'small' => true,
    'default' => true, // Default: false
  ];
  
  return $controls;
} );

Once I added this code I would like to add custom class, or attribute (manipulate the render of this element) based on the checked y/n value. But I can’t achieve the render part… could you help me with this ?

Thank a lot!

Hi,

I have the same problem. I added a custom control to allow users to add a .vtt file to a video element (using the ‘bricks/elements/video/controls’ filter).

However, now I need to change the rendering (edit the html of element with condition). I haven’t found any filter to do this. Any tips?

Thanks!

Same here. Looking for a way to add a control to existing elements that will (1) set a class name and (2) alter the HTML, and that will do so live when changed in the builder as well as the frontend. bricks/element/render_attributes doesn’t update when the custom field value is changed, and bricks/frontend/render_element doesn’t do anything at all in the builder.