private function show_edit_form()
    {
        /*
         * The user created the entry, so show them the form!
         */
        if (self::$allowed_edit === false) {
            /*
             * TODO add error log message here 
             */
            return false;
        }
        ob_start();
        $form = self::$form;
        $lead = self::$lead;
        $form_id = $form['id'];
        $field_values = array();
        $is_postback = false;
        /*
         * Validate form, if submitted 
         */
        if (isset($_POST['gform_submit'])) {
            $is_postback = true;
            $is_valid = $this->validate($form, $field_values);
            if ($is_valid) {
                /*
                 * TODO, save the form and show an update message 
                 */
                if ($this->update_entry($form, $lead)) {
                    GFPDFEWidgetsAndShortcode_PDFDisplay::$message = __('Your entry and PDF(s) has been successfully updated.', 'pdfextended');
                } else {
                    GFPDFEWidgetsAndShortcode_PDFDisplay::$error = __('There was a problem updating your entry. Please try again.', 'pdfextended');
                }
                return false;
            }
        }
        ?>

		<div id="gform_wrapper_<?php 
        echo self::$form['id'];
        ?>
" class='gform_wrapper'>
			<form id="gform_<?php 
        echo self::$form['id'];
        ?>
" method="post">
				<div id='gform_page_<?php 
        echo self::$form['id'];
        ?>
_1'>
	                 <div class='gform_page_fields'>	

						<?php 
        if ($is_postback && !$is_valid) {
            $validation_message = "<div class='validation_error'>" . __("There was a problem with your submission.", "gravityforms") . " " . __("Errors have been highlighted below.", "gravityforms") . "</div>";
            echo apply_filters("gform_validation_message_{$form["id"]}", apply_filters("gform_validation_message", $validation_message, $form), $form);
        }
        ?>

	                 	<ul id='gform_fields_<?php 
        echo self::$form['id'];
        ?>
' class='gform_fields'>
				        					               
				                    <?php 
        foreach ($form["fields"] as $field) {
            $field_id = $field["id"];
            /*
             * If $field_id should be hidden...
             */
            if (in_array($field_id, $this->atts['hidden_fields'])) {
                continue;
            }
            $field["conditionalLogicFields"] = GFFormDisplay::get_conditional_logic_fields($form, $field["id"]);
            $input_type = RGFormsModel::get_input_type($field);
            $error_class = rgget("failed_validation", $field) ? "gfield_error" : "";
            $admin_only_class = rgget("adminOnly", $field) ? "field_admin_only" : "";
            $selectable_class = IS_ADMIN ? "selectable" : "";
            $hidden_class = in_array($input_type, array("hidden", "hiddenproduct")) ? "gform_hidden" : "";
            $section_class = $field["type"] == "section" ? "gsection" : "";
            $page_class = $field["type"] == "page" ? "gpage" : "";
            $html_block_class = $field["type"] == "html" ? "gfield_html" : "";
            $html_formatted_class = $field["type"] == "html" && !IS_ADMIN && !rgget("disableMargins", $field) ? "gfield_html_formatted" : "";
            $html_no_follows_desc_class = $field["type"] == "html" && !IS_ADMIN && !self::prev_field_has_description(self::$form, $field["id"]) ? "gfield_no_follows_desc" : "";
            $calculation_class = RGFormsModel::get_input_type($field) == 'number' && GFCommon::has_field_calculation($field) ? 'gfield_calculation' : '';
            $calculation_class = RGFormsModel::get_input_type($field) == 'calculation' ? 'gfield_calculation' : '';
            $product_suffix = '_' . self::$form['id'] . '_' . rgget("productField", $field);
            $option_class = $field["type"] == "option" ? "gfield_price gfield_price{$product_suffix} gfield_option{$product_suffix}" : "";
            $quantity_class = $field["type"] == "quantity" ? "gfield_price gfield_price{$product_suffix} gfield_quantity{$product_suffix}" : "";
            $shipping_class = $field["type"] == "shipping" ? "gfield_price gfield_shipping gfield_shipping_{$form["id"]}" : "";
            $product_class = $field["type"] == "product" ? "gfield_price gfield_price_{$form["id"]}_{$field["id"]} gfield_product_{$form["id"]}_{$field["id"]}" : "";
            $hidden_product_class = $input_type == "hiddenproduct" ? "gfield_hidden_product" : "";
            $donation_class = $field["type"] == "donation" ? "gfield_price gfield_price_{$form["id"]}_{$field["id"]} gfield_donation_{$form["id"]}_{$field["id"]}" : "";
            $required_class = rgar($field, "isRequired") ? "gfield_contains_required" : "";
            $creditcard_warning_class = $input_type == "creditcard" && !GFCommon::is_ssl() ? "gfield_creditcard_warning" : "";
            $custom_class = IS_ADMIN ? "" : rgget("cssClass", $field);
            $css_class = "{$selectable_class} gfield {$error_class} {$section_class} {$admin_only_class} {$custom_class} {$hidden_class} {$html_block_class} {$html_formatted_class} {$html_no_follows_desc_class} {$option_class} {$quantity_class} {$product_class} {$donation_class} {$shipping_class} {$page_class} {$required_class} {$hidden_product_class} {$creditcard_warning_class} {$calculation_class}";
            $css_class = apply_filters("gform_field_css_class_" . self::$form["id"], apply_filters("gform_field_css_class", trim($css_class), $field, self::$form), $field, self::$form);
            $style = !empty($form) && !IS_ADMIN && RGFormsModel::is_field_hidden(self::$form, $field, $field_values) ? "style='display:none;'" : "";
            switch (RGFormsModel::get_input_type($field)) {
                case "captcha":
                case "html":
                case "password":
                case "product":
                case "coupon":
                case "quantity":
                case "shipping":
                case "donation":
                case "total":
                case "singleproduct":
                case "hiddenproduct":
                case "singleshipping":
                case "creditcard":
                case "page":
                case "post_image":
                case "fileupload":
                    //ignore certain fields
                    continue;
                    break;
                default:
                    if (isset($field['productField']) && (int) $field['productField'] > 0 || $field['type'] == 'shipping') {
                        continue;
                    }
                    /*
                     * Ensure our restricted field values stay the same (as they aren't push through the $_POST data)
                     */
                    if (in_array($field_id, $this->atts['restricted_fields'])) {
                        $value = RGFormsModel::get_lead_field_value($lead, $field);
                    } else {
                        /*
                         * Check if we have POST data, or whether we pull the details from the entry itself 
                         * This is useful when the validation fails
                         */
                        $value = $is_postback ? RGFormsModel::get_field_value($field) : RGFormsModel::get_lead_field_value($lead, $field);
                    }
                    $id = "field_" . $form['id'] . "_" . $field_id;
                    /* $content = " <li id='{$id}' class='$css_class' $style><label class='detail-label'>" . esc_html(GFCommon::get_label($field)) . "</label>" .
                    				                                           GFCommon::get_field_input($field, $value, $lead["id"], $form['id']) . "</li>";
                    
                    				                                $content = apply_filters("gform_field_content", $content, $field, $value, self::$lead["id"], self::$form["id"]);*/
                    //$content = "<li id='{$id}' class='$css_class' $style>" . GFFormDisplay::get_field_content($field, $value, true, $form['id']) . '</li>';
                    $field_content = GFFormDisplay::get_field_content($field, $value, true, $form['id']);
                    $field_container = "<li id='{$id}' class='{$css_class}' {$style}>{FIELD_CONTENT}</li>";
                    $field_container = apply_filters('gform_field_container', $field_container, $field, $form, $css_class, $style, $field_content);
                    $field_container = apply_filters("gform_field_container_{$form['id']}", $field_container, $field, $form, $css_class, $style, $field_content);
                    $field_container = apply_filters("gform_field_container_{$form['id']}_{$field['id']}", $field_container, $field, $form, $css_class, $style, $field_content);
                    $field_markup = str_replace('{FIELD_CONTENT}', $field_content, $field_container);
                    if (in_array($field_id, $this->atts['restricted_fields'])) {
                        $field_markup = str_replace('<input', '<input disabled', $field_markup);
                        $field_markup = str_replace('<textarea', '<textarea disabled', $field_markup);
                    }
                    echo $field_markup;
                    break;
            }
        }
        $field_values_str = is_array($field_values) ? http_build_query($field_values) : $field_values;
        ?>
				              

						            <input type='hidden' class='gform_hidden' name='is_submit_<?php 
        echo $form['id'];
        ?>
' value='1' />
						            <input type='hidden' class='gform_hidden' name='gform_submit' value='<?php 
        echo $form['id'];
        ?>
' />
						            <input type='hidden' class='gform_hidden' name='gform_unique_id' value='<?php 
        echo esc_attr(GFFormsModel::get_form_unique_id($form['id']));
        ?>
' />
						            <input type='hidden' class='gform_hidden' name='state_<?php 
        echo $form['id'];
        ?>
' value='<?php 
        GFFormDisplay::get_state($form, $field_values);
        ?>
' />						            
						            <input type='hidden' name='gform_field_values' value='<?php 
        echo esc_attr($field_values_str);
        ?>
' />					

				                    <?php 
        $button_input = self::get_form_button($form["id"], "gform_submit_button_{$form["id"]}", $form["button"], __("Submit", "gravityforms"), "button gform_button", __("Submit", "gravityforms"));
        echo $button_input;
        ?>
				         	
				         	</ul>
				        </div>
				    </div>
			</form>				    
         </div>

        <?php 
        $html = ob_get_contents();
        ob_end_clean();
        return $html;
    }
 private static function get_conditional_logic($form, $field_values = array())
 {
     $logics = '';
     $dependents = '';
     $fields_with_logic = array();
     $default_values = array();
     foreach ($form['fields'] as $field) {
         /* @var GF_Field $field */
         $field_deps = GFFormDisplay::get_conditional_logic_fields($form, $field->id);
         $field_dependents[$field->id] = !empty($field_deps) ? $field_deps : array();
         //use section's logic if one exists
         $section = RGFormsModel::get_section($form, $field->id);
         $section_logic = !empty($section) ? rgar($section, 'conditionalLogic') : null;
         $field_logic = $field->type != 'page' ? $field->conditionalLogic : null;
         //page break conditional logic will be handled during the next button click
         $next_button_logic = !empty($field->nextButton) && !empty($field->nextButton['conditionalLogic']) ? $field->nextButton['conditionalLogic'] : null;
         if (!empty($field_logic) || !empty($next_button_logic)) {
             $field_section_logic = array('field' => $field_logic, 'nextButton' => $next_button_logic, 'section' => $section_logic);
             $logics .= $field->id . ': ' . GFCommon::json_encode($field_section_logic) . ',';
             $fields_with_logic[] = $field->id;
             $peers = $field->type == 'section' ? GFCommon::get_section_fields($form, $field->id) : array($field);
             $peer_ids = array();
             foreach ($peers as $peer) {
                 $peer_ids[] = $peer->id;
             }
             $dependents .= $field->id . ': ' . GFCommon::json_encode($peer_ids) . ',';
         }
         //-- Saving default values so that they can be restored when toggling conditional logic ---
         $field_val = '';
         $input_type = $field->get_input_type();
         $inputs = $field->get_entry_inputs();
         //get parameter value if pre-populate is enabled
         if ($field->allowsPrepopulate) {
             if ($input_type == 'checkbox') {
                 $field_val = RGFormsModel::get_parameter_value($field->inputName, $field_values, $field);
                 if (!is_array($field_val)) {
                     $field_val = explode(',', $field_val);
                 }
             } elseif (is_array($inputs)) {
                 $field_val = array();
                 foreach ($inputs as $input) {
                     $field_val["input_{$input['id']}"] = RGFormsModel::get_parameter_value(rgar($input, 'name'), $field_values, $field);
                 }
             } elseif ($input_type == 'time') {
                 // maintained for backwards compatibility. The Time field now has an inputs array.
                 $parameter_val = RGFormsModel::get_parameter_value($field->inputName, $field_values, $field);
                 if (!empty($parameter_val) && preg_match('/^(\\d*):(\\d*) ?(.*)$/', $parameter_val, $matches)) {
                     $field_val = array();
                     $field_val[] = esc_attr($matches[1]);
                     //hour
                     $field_val[] = esc_attr($matches[2]);
                     //minute
                     $field_val[] = rgar($matches, 3);
                     //am or pm
                 }
             } elseif ($input_type == 'list') {
                 $parameter_val = RGFormsModel::get_parameter_value($field->inputName, $field_values, $field);
                 $field_val = is_array($parameter_val) ? $parameter_val : explode(',', str_replace('|', ',', $parameter_val));
                 if (is_array(rgar($field_val, 0))) {
                     $list_values = array();
                     foreach ($field_val as $row) {
                         $list_values = array_merge($list_values, array_values($row));
                     }
                     $field_val = $list_values;
                 }
             } else {
                 $field_val = RGFormsModel::get_parameter_value($field->inputName, $field_values, $field);
             }
         }
         //use default value if pre-populated value is empty
         $field_val = $field->get_value_default_if_empty($field_val);
         if (is_array($field->choices) && $input_type != 'list') {
             //radio buttons start at 0 and checkboxes start at 1
             $choice_index = $input_type == 'radio' ? 0 : 1;
             $is_pricing_field = GFCommon::is_pricing_field($field->type);
             foreach ($field->choices as $choice) {
                 if ($input_type == 'checkbox' && $choice_index % 10 == 0) {
                     $choice_index++;
                 }
                 $is_prepopulated = is_array($field_val) ? in_array($choice['value'], $field_val) : $choice['value'] == $field_val;
                 $is_choice_selected = rgar($choice, 'isSelected') || $is_prepopulated;
                 if ($is_choice_selected && $input_type == 'select') {
                     $price = GFCommon::to_number(rgar($choice, 'price')) == false ? 0 : GFCommon::to_number(rgar($choice, 'price'));
                     $val = $is_pricing_field && $field->type != 'quantity' ? $choice['value'] . '|' . $price : $choice['value'];
                     $default_values[$field->id] = $val;
                 } elseif ($is_choice_selected) {
                     if (!isset($default_values[$field->id])) {
                         $default_values[$field->id] = array();
                     }
                     $default_values[$field->id][] = "choice_{$form['id']}_{$field->id}_{$choice_index}";
                 }
                 $choice_index++;
             }
         } elseif (!empty($field_val)) {
             switch ($input_type) {
                 case 'date':
                     // for date fields; that are multi-input; and where the field value is a string
                     // (happens with prepop, default value will always be an array for multi-input date fields)
                     if (is_array($field->inputs) && (!is_array($field_val) || !isset($field_val['m']))) {
                         $format = empty($field->dateFormat) ? 'mdy' : esc_attr($field->dateFormat);
                         $date_info = GFcommon::parse_date($field_val, $format);
                         // converts date to array( 'm' => 1, 'd' => '13', 'y' => '1987' )
                         $field_val = $field->get_date_array_by_format(array($date_info['month'], $date_info['day'], $date_info['year']));
                     }
                     break;
                 case 'time':
                     if (is_array($field_val)) {
                         $ampm_key = key(array_slice($field_val, -1, 1, true));
                         $field_val[$ampm_key] = strtolower($field_val[$ampm_key]);
                     }
                     break;
                 case 'address':
                     $state_input_id = sprintf('%s.4', $field->id);
                     if (isset($field_val[$state_input_id]) && !$field_val[$state_input_id]) {
                         $field_val[$state_input_id] = $field->defaultState;
                     }
                     $country_input_id = sprintf('%s.6', $field->id);
                     if (isset($field_val[$country_input_id]) && !$field_val[$country_input_id]) {
                         $field_val[$country_input_id] = $field->defaultCountry;
                     }
                     break;
             }
             $default_values[$field->id] = $field_val;
         }
     }
     $button_conditional_script = '';
     //adding form button conditional logic if enabled
     if (isset($form['button']['conditionalLogic'])) {
         $logics .= '0: ' . GFCommon::json_encode(array('field' => $form['button']['conditionalLogic'], 'section' => null)) . ',';
         $dependents .= '0: ' . GFCommon::json_encode(array(0)) . ',';
         $fields_with_logic[] = 0;
         $button_conditional_script = "jQuery('#gform_{$form['id']}').submit(" . 'function(event, isButtonPress){' . '    var visibleButton = jQuery(".gform_next_button:visible, .gform_button:visible, .gform_image_button:visible");' . '    return visibleButton.length > 0 || isButtonPress == true;' . '}' . ');';
     }
     if (!empty($logics)) {
         $logics = substr($logics, 0, strlen($logics) - 1);
     }
     //removing last comma;
     if (!empty($dependents)) {
         $dependents = substr($dependents, 0, strlen($dependents) - 1);
     }
     //removing last comma;
     $animation = rgar($form, 'enableAnimation') ? '1' : '0';
     global $wp_locale;
     $number_format = $wp_locale->number_format['decimal_point'] == ',' ? 'decimal_comma' : 'decimal_dot';
     $str = "if(window['jQuery']){" . "if(!window['gf_form_conditional_logic'])" . "window['gf_form_conditional_logic'] = new Array();" . "window['gf_form_conditional_logic'][{$form['id']}] = { logic: { {$logics} }, dependents: { {$dependents} }, animation: {$animation}, defaults: " . json_encode($default_values) . ", fields: " . json_encode($field_dependents) . " }; " . "if(!window['gf_number_format'])" . "window['gf_number_format'] = '" . $number_format . "';" . 'jQuery(document).ready(function(){' . "gf_apply_rules({$form['id']}, " . json_encode($fields_with_logic) . ', true);' . "jQuery('#gform_wrapper_{$form['id']}').show();" . "jQuery(document).trigger('gform_post_conditional_logic', [{$form['id']}, null, true]);" . $button_conditional_script . '} );' . '} ';
     return $str;
 }