How to handle 'Brick'?


I want to add a custom checkbox to a custom field with $input = new Brick('input', null);
This is the desired markup:

<input id="one" type="checkbox" class="choice-list__checkbox" checked>
<label for="one" class="choice-list__label">Choice one</label>

Then i want to prepend a simple text output after the checkbox:

$diff = new Brick('div', null);
$wrapper->append(nl2br('<div class="audit-diff-box">'.$diffhtml).'</div>');

But this is inside the checkbox container. How i prepend it after the checkbox container?


I haven’t tested this, but you might want to test the following snippet:

$wrapper = brick('div');

$checkbox = brick('input', null, [
  'class' => 'choice-list__checkbox',
  'type' => 'checkbox',
  'id'   => 'one',

$label = brick('label', 'Choice one', [
  'class' => 'choice-list__label',
  'for'   => 'one',

$diff = brick('div', nl2br($diffhtml), ['class' => 'audit-diff-box']);

  <input class="choice-list__checbox" type="checkbox" id="one" />
  <label class="choice-list__label" for="one">Choice one</label>
  <div class="audit-diff-box">…</div>