Created
February 23, 2015 22:14
-
-
Save gicolek/0b176d2e267fe210dd21 to your computer and use it in GitHub Desktop.
Gravity Forms Custom Checkbox Input layout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( "gform_field_input", "checkbox_input", 10, 5 ); | |
/** | |
* Filter the input to be a differently structured checkbox input | |
* | |
* @hook gform_field_input | |
*/ | |
function checkbox_input($input, $field, $value, $lead_id, $form_id) { | |
// if the field has a CSS 'ch' class assigned, let's modify its output for the sake of easier CSS | |
if ( $field["cssClass"] == "ch" ) { | |
// to simplify the output lets use output buffering | |
ob_start(); | |
?> | |
<label class = "check-box"> | |
<input name="input_<?php echo $field['id']; ?>" id="input_<?php echo $form_id; ?>_<?php echo $field['id']; ?>" type = "checkbox" <?php checked( $value ); ?> /> By joining I agree to receive updates, newsletters and agree to the terms & conditions & privacy policy | |
</label> | |
<?php | |
$input = ob_get_clean(); | |
} | |
return $input; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment