PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Splitting up form elements

  1. I'm sure that there is a better way to do this, but for those who may find this of any use... I needed to figure out a really quick way to split up my form elements:

    screenshot: http://d.pr/LifK

    here is the function i created that hooks into gform_field_content to create multiple ul's that i was then able to style accordingly:

    ( fyi: cheezcap_get_option is function I made that gets custom fields from my cheezcap configuration for WP: https://github.com/cheezburger/cheezcap )

    add_filter( 'gform_field_content', 'bbtf_gravity_forms_hook', 10, 5 );
    
    /**
     * Hook into gform_field_content to split up input fields for Gravity Forms
     *
     * @access public
     * @param  mixed $content
     * @param  mixed $field
     * @param  mixed $value
     * @param  mixed $lead_id
     * @param  mixed $form_id
     * @return void
     * @author moimikey
     */
    function bbtf_gravity_forms_hook( $content, $field, $value, $lead_id, $form_id ) {
    	$contact_info = '<div class="sub-head-bar"><div class="sub-head-img"><img src="/img/pages/reservations/reservations_contact_info.png" class="aligncenter"></div></div>';
    
    	$form_reservations_only = cheezcap_get_option( 'bbtf_gravity_reserve', false, 'absint' );
    	$form_vip_rooms = cheezcap_get_option( 'bbtf_gravity_vip', false, 'absint' );
    
    	if( $form_id == $form_reservations_only ) {
    		if( $field["id"] == 4 ) {
    			$content .= '</ul>' . $contact_info . '<ul id=\'gform_fields_' . $form_reservations_only . '\' class=\'gform_fields top_label description_below\'>';
    		}
    
    		if( $field["id"] == 8 ) {
    			$content .= '</ul><ul id=\'gform_fields_' . $form_reservations_only . '\' class=\'gform_fields top_label description_below\' style="float:right;">';
    		}
    	} elseif( $form_id == $form_vip_rooms ) {
    		if( $field["id"] == 21 ) {
    			$content .= '</ul>' . $contact_info . '<ul id=\'gform_fields_' . $form_reservations_only . '\' class=\'gform_fields top_label description_below\'>';
    		}
    
    		if( $field["id"] == 8 ) {
    			$content .= '</ul><ul id=\'gform_fields_' . $form_reservations_only . '\' class=\'gform_fields top_label description_below\' style="float:right;">';
    		}
    	}
    
    	return $content;
    }
    Posted 12 years ago on Monday November 28, 2011 | Permalink
  2. Thank you for posting that code. I'm sure someone will find it useful.

    Posted 12 years ago on Thursday December 1, 2011 | Permalink