• Resolved marcorm69

    (@marcorm69)


    Hi all.

    I need to add a upload file a form module.
    I have implemented this code and working fine

    
    <?php
    
    /**
     * Make the Give Donation form a multipart/form-data form
     *
     */
    
    function give_add_multipart_tag_donation_form( $final_output, $args ) {
        $form_tag = "<form id=\"give-form-{$args['form_id']}-1\"";
    	$final_output = str_replace( $form_tag, "{$form_tag} enctype=\"multipart/form-data\"", $final_output );
    
    	return $final_output;
    }
    
    add_filter( 'give_donate_form', 'give_add_multipart_tag_donation_form', 10, 2 );
    

    The problem arises when, in the same page, i have more form module.
    The form id is so composed

    <form id=”give-form-XXXXX-n”>

    where
    – XXXXX is the form-id;
    – n is a progressive form number;

    I don’t know how to do to implement the dynamic “n” in the code above.

    Can you help me?

    Regards,
    Marco

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter marcorm69

    (@marcorm69)

    I am sorry.

    I am an idiot!!!
    I have resolve with a regular expression

    $final_output = preg_replace('/(<form id="give-form-[0-9]*-[0-9]*")/', '$1 enctype="multipart/form-data"', $final_output);
    
    abihordun

    (@abihordun)

    Have tried this several times but it’s not working for me

    My reagards
    Techevangelist

    • This reply was modified 9 months ago by abihordun.
    • This reply was modified 9 months ago by abihordun.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add enctype to form’ is closed to new replies.