-
-
Save cdils/a7744d15f32b1cc140abf83bc4e675be to your computer and use it in GitHub Desktop.
This file contains 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 | |
// Format: gform_column_input_content_FORMID_FIELDID_COLUMN. | |
add_filter( 'gform_column_input_content_3_1_4', 'pbj_crust_option', 10, 6 ); | |
function pbj_crust_option( $input, $input_info, $field, $text, $value, $form_id ) { | |
// Field name needs to match List field syntax. | |
$field_name = 'input_' . $field->id . '[]'; | |
// We want tabindex for keyboard accessibility. | |
$tabindex = GFCommon::get_tabindex(); | |
// Build the HTML output. | |
$new_input = '<input type="checkbox" name="' . $field_name . '" ' . $tabindex . '"/>'; | |
return $new_input; | |
} |
This file contains 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 | |
// Format: gform_column_input_FORMID_FIELDID_COLUMN. | |
add_filter( 'gform_column_input_3_1_2', 'pbj_pb_selections' ); | |
function pbj_pb_selections() { | |
$pb_types = array( | |
'type' => 'select', | |
'choices' => array( 'Cashew Butter', 'Peanut Butter', 'Sun Butter' ), | |
); | |
return $pb_types; | |
} | |
// Format: gform_column_input_FORMID_FIELDID_COLUMN. | |
add_filter( 'gform_column_input_3_1_3', 'pbj_jelly_selections' ); | |
function pbj_jelly_selections() { | |
$jelly_flavors = array( | |
'type' => 'select', | |
'choices' => array( 'Grape', 'Strawberry', 'Raspberry' ), | |
); | |
return $jelly_flavors; | |
} |
This file contains 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 | |
// Replace 4 with your FORM ID. | |
add_filter( 'gform_form_post_get_meta_4', 'sandwich_creations_repeater' ); | |
function sandwich_creations_repeater( $form ) { | |
// Create a Single Line text field for the sandwich name. | |
$sandwich_name = GF_Fields::create( | |
array( | |
'type' => 'text', | |
'id' => 1003, // The Field ID must be unique on the form. | |
'formId' => $form['id'], | |
'label' => 'Sandwich', | |
) | |
); | |
// Create a textarea field for the sandwich description. | |
$sandwich_description = GF_Fields::create( | |
array( | |
'type' => 'textarea', | |
'id' => 1002, // The Field ID must be unique on the form | |
'formId' => $form['id'], | |
'label' => 'Description', | |
'size' => 'small', | |
) | |
); | |
// Create an email field for the team member's email address | |
$sandwich_type = GF_Fields::create( | |
array( | |
'type' => 'radio', | |
'id' => 1001, // The Field ID must be unique on the form | |
'formId' => $form['id'], | |
'label' => 'Sandwich type', | |
'choices' => array( | |
array( | |
'text' => 'Carnivore', | |
), | |
array( | |
'text' => 'Vegetarian', | |
), | |
), | |
) | |
); | |
// Create a repeater for the sandwiches and add the newly created fields to display inside the repeater. | |
$sandwich_repeater = GF_Fields::create( | |
array( | |
'type' => 'repeater', | |
'id' => 1000, // The Field ID must be unique on the form | |
'formId' => $form['id'], | |
'label' => 'Sandwiches', | |
'addButtonText' => 'Add another sandwich', // Optional | |
'fields' => array( $sandwich_name, $sandwich_description, $sandwich_type ), // Add the fields here. | |
) | |
); | |
$form['fields'][] = $sandwich_repeater; | |
return $form; | |
} |
This file contains 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 | |
// Replace 5 with your FORM ID. | |
add_filter( 'gform_form_post_get_meta_5', 'time_tracking_repeater' ); | |
function time_tracking_repeater( $form ) { | |
$task_name = GF_Fields::create( | |
array( | |
'type' => 'text', | |
'id' => 1000, | |
'formId' => $form['id'], | |
'label' => 'Task', | |
) | |
); | |
$task_description = GF_Fields::create( | |
array( | |
'type' => 'textarea', | |
'id' => 1001, | |
'formId' => $form['id'], | |
'label' => 'Description', | |
'size' => 'small', | |
) | |
); | |
$date = GF_Fields::create( | |
array( | |
'type' => 'date', | |
'id' => 1002, | |
'formId' => $form['id'], | |
'label' => 'Date', | |
'size' => 'small', | |
) | |
); | |
$start_time = GF_Fields::create( | |
array( | |
'type' => 'time', | |
'id' => 1003, | |
'formId' => $form['id'], | |
'label' => 'Start Time', | |
'size' => 'small', | |
) | |
); | |
$end_time = GF_Fields::create( | |
array( | |
'type' => 'time', | |
'id' => 1004, | |
'formId' => $form['id'], | |
'label' => 'End Time', | |
'size' => 'small', | |
) | |
); | |
$nested_repeater = GF_Fields::create( | |
array( | |
'type' => 'repeater', | |
'id' => 1005, // The Field ID must be unique on the form | |
'formId' => $form['id'], | |
'label' => 'Time Entry', | |
'addButtonText' => 'Add another time entry', | |
'fields' => array( $date, $start_time, $end_time ), | |
) | |
); | |
$task_repeater = GF_Fields::create( | |
array( | |
'type' => 'repeater', | |
'id' => 1006, // The Field ID must be unique on the form | |
'formId' => $form['id'], | |
'label' => 'Tasks', | |
'addButtonText' => 'Add another task', | |
'fields' => array( $task_name, $task_description, $nested_repeater ), | |
) | |
); | |
$form['fields'][] = $task_repeater; | |
return $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment