Skip to content

Instantly share code, notes, and snippets.

@mattkeys
Created December 26, 2013 15:47
Show Gist options
  • Save mattkeys/8135256 to your computer and use it in GitHub Desktop.
Save mattkeys/8135256 to your computer and use it in GitHub Desktop.
Gravity Forms business
// GRAVITY FORMS SUBMIT BUTTON STYLING
function form_submit_button($button, $form){
return "<input type='submit' id='gform_submit_button_{$form["id"]}' class='btn' value='Send Email'>";
}
add_filter("gform_submit_button_1", "form_submit_button", 10, 2);
// REMOVING GRAVITY FORMS FIELD LABELS
function form_required_label($content, $field, $value, $lead_id, $form_id){
$types = array('radio','checkbox','textarea','hidden');
if(in_array($field['type'], $types)) {
$type = $field['type'];
} else {
$type = "text";
}
if($type == "text" || $type == "textarea") {
$content = str_replace("label class='", "label class='oldbrowser ", $content);
}
return $content;
}
add_filter("gform_field_content", "form_required_label", 10, 5);
// INJECTING PLACEHOLDERS INTO GRAVITY FORMS INPUTS && APPENDING CLASSES TO CHECKBOXES FOR VALIDATION
function form_input_placeholder($input, $field, $value, $lead_id, $form_id){
$types = array('radio','checkbox','textarea','hidden');
if(in_array($field['type'], $types)) {
$type = $field['type'];
} else {
$type = "text";
}
if($form_id == 1) {
switch($type) {
case 'text':
if($field['label'] == 'Email Address') {
$input = "<input name='input_{$field["id"]}' id='input_{$form_id}_{$field["id"]}' placeholder='{$field["label"]}' type='$type' value='{$field["defaultValue"]}' class='{$field["size"]} {$field["cssClass"]} validate[required,custom[email]]'>";
} else {
$input = "<input name='input_{$field["id"]}' id='input_{$form_id}_{$field["id"]}' placeholder='{$field["label"]}' type='$type' value='{$field["defaultValue"]}' class='{$field["size"]} {$field["cssClass"]} validate[required]'>";
}
break;
case 'textarea':
$input = "<textarea name='input_{$field["id"]}' id='input_{$form_id}_{$field["id"]}' placeholder='{$field["label"]}' class='{$field["size"]} textarea {$field["cssClass"]} validate[required]' rows='10' cols='50'></textarea>";
break;
}
return $input;
}
}
add_filter("gform_field_input", "form_input_placeholder", 10, 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment