implement checkbox or toggle switch in plugin code

Question

I need to implement a way to let the user decode a base64 string from the front-end. I want to add a toggle switch or a checkbox that if selected will encode or decode the input string. Is there a way to manage this on the backend of my plugin? I mean, if the user toggle the bs4 switch on or check the form control, the plugin will know what kind of operation do on the input text? any example will be appreciated
NB: I’m using a shortcode to render the HTML

bootstrap toggle switch

public function switch_form( array $attr, string $content = null ) : string
{
ob_start();
?>
<div class="custom-control custom-switch">
  <input type="checkbox" class="custom-control-input" id="customSwitch1">
  <label class="custom-control-label" for="customSwitch1">Toggle this switch element</label>
</div>
<?php
return ob_get_clean();
}

bootstrap checkbox

public function switch_form( array $attr, string $content = null ) : string
{
ob_start();
?>
<div class="custom-control custom-radio">
  <input type="radio" id="customRadio1" name="customRadio" class="custom-control-input">
  <label class="custom-control-label" for="customRadio1">Toggle this custom radio</label>
</div>
<div class="custom-control custom-radio">
  <input type="radio" id="customRadio2" name="customRadio" class="custom-control-input">
  <label class="custom-control-label" for="customRadio2">Or toggle this other custom radio</label>
</div>
<?php
return ob_get_clean();
}
0
, , sialfa 2 years 2020-01-07T08:41:02-05:00 0 Answers 81 views 0

Leave an answer

Browse
Browse