• Hello there,

    I have the following code and with the new update the tag stopped working. I dont understand what is going on. Any help is appreciated.

    add_action('wpcf7_init', 'custom_form_tag_qty');
    
    function custom_form_tag_qty() {
    
        wpcf7_add_form_tag(array('qty'), 'custom_qty_form_tag_handler', true);
    
    }
    
    function custom_qty_generate_input_unique_name($init, $tab, $row, $field) {
    
        return $init . '____' . $tab . '____' . $row . '____' . $field;
    
    }
    
    function custom_qty_form_tag_handler($tag) {
    
        $tag = new WPCF7_FormTag($tag);
    
        $atts = array();
    
        $atts['id'] = $tag->get_id_option();
    
        $atts['name'] = $tag->name;
    
        $atts = wpcf7_format_atts($atts);
    
        $myCustomField = '
    
        <div class="row b2b__info-table-title">
    
            <div class="col-7">
    
                <div class="b2b__info-table-cell font-noto">' . $tag->raw_values[2] . '</div>
    
            </div>
    
            <div class="col-5">
    
                <div class="b2b__info-table-cell font-noto">'.__('Ποσότητα', 'theme-name').'</div>
    
            </div>
    
        </div>
    
        <div class="row b2b__info-table-data">
    
        ';
    
        foreach ($tag->raw_values as $key => $value) {
    
            if ($key > 2) {
    
                $myCustomField .= '
    
                    <div class="col-7">
    
                        <div class="b2b__info-table-cell">' . $value . '</div>
    
                    </div>
    
                    <div class="col-5">
    
                        <div class="b2b__info-table-cell">
    
                            <div class="b2b__input-container">
    
                                <div class="b2b__input-minus">-</div>
    
                                <input type="number" class="b2b__input" value="0" name="' . custom_qty_generate_input_unique_name($tag->raw_values[0], $tag->raw_values[1], $tag->raw_values[2], $value) . '" min="0" max="999">
    
                                <div class="b2b__input-plus">+</div>
    
                            </div>
    
                        </div>
    
                    </div>
    
                ';
    
            }
    
        }
    
        $myCustomField .= '</div>';
    
        return $myCustomField;
    
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi!
    What form-tag do you have in the body of the form, [qty], right?

    Thread Starter nikoioan

    (@nikoioan)

    Hi,

    [qty "qty" "Χαλβάς" "Χαλβάς βανίλια" "Τάπερ 450gr" "Τάπερ 900gr" "Μπαστούνι 2,5kg" "Δοχείο 5kg"]

    So, you only have the values, but in your solution the name is mandatory – the last parameter in the following line of your code:

    wpcf7_add_form_tag(array('qty'), 'custom_qty_form_tag_handler', true);

    Most likely adding a name for form-tag is enough:
    https://contactform7.com/tag-syntax/#form_tag

    PS: the following locations for version 5.7.3
    contact-form-7/includes/form-tags-manager.php:6
    contact-form-7/includes/form-tags-manager.php:110
    contact-form-7/includes/form-tags-manager.php:504

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Custom tag broke with new update’ is closed to new replies.