This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Remove dash from checkbox field in email


  1. discosteve
    Member

    I have a number of checkbox fields on several different forms. When the form entries are emailed the checkbox fields include a dash ("-") in front of the selection. So if the user selected Option 1 in the checkbox field, it comes through on the email as "- Option 1".

    Is there a way to remove this dash on the email? I tried the solution presented here - http://www.appnitro.com/forums/topic/-in-subject-line?replies=7, but that doesn't seem to do anything. I'd like to not have to specify every field and element that I want to remove the dash for because it's a really long list.

    Thanks!

    Posted 14 years ago #
  2. redityo

    The method in that link should work. Try to change these code for that post

    if($data['element_type'] == 'textarea'){
    	$template_values[$i] = nl2br($data['value']);
    } elseif ($data['element_type'] == 'checkbox' && $form_id == '16' && $data['element_id'] == '1' ) {
    	$template_values[$i] = str_replace('-',' ',$data['value']);
    }elseif ($data['element_type'] == 'file'){
    	if($target_is_admin === false){
    		$template_values[$i] = strip_tags($data['value']);
    	}else{
    		$template_values[$i] = strip_tags($data['value'],'<a>');
    	}
    }else{
    	$template_values[$i]	= $data['value'];
    }

    to

    if($data['element_type'] == 'textarea'){
    	$template_values[$i] = nl2br($data['value']);
    } elseif ($data['element_type'] == 'checkbox' ) {
    	$template_values[$i] = str_replace('-',' ',$data['value']);
    }elseif ($data['element_type'] == 'file'){
    	if($target_is_admin === false){
    		$template_values[$i] = strip_tags($data['value']);
    	}else{
    		$template_values[$i] = strip_tags($data['value'],'<a>');
    	}
    }else{
    	$template_values[$i]	= $data['value'];
    }

    That would make the customization applied to all check box field type.
    if it still not work, you can send me your "helper-functions.php" file to :

    customer.service[at]appnitro.com

    I will help you to check it


    MachForm Support

    Posted 14 years ago #
  3. discosteve
    Member

    Thanks redityo. The modified code doesn't seem to be working still. I'll send you an email with my helper-functions.php file now.

    Posted 14 years ago #
  4. Willy
    Member

    Hello,

    I am interested in achieving the same thing and have been trying to use the code as described and I also tried some additional changes but the dash won't disappear.

    The additional changes I made were in the code that appears on lines 372 - 386 in helper-functions.php,

    if($data['element_type'] == 'textarea'){
    $email_body .= "<b>{$data['label']}</b> ".nl2br($data['value'])."\n";
    }elseif ($data['element_type'] == 'checkbox' || $data['element_type'] == 'address'){
    $email_body .= "<b>{$data['label']}</b> ".$data['value']."\n";
    }elseif ($data['element_type'] == 'file'){
    if($target_is_admin === false){
    $data['value'] = strip_tags($data['value']);
    $email_body .= "<b>{$data['label']}</b> - {$data['value']} \n";
    }else{
    $data['value'] = strip_tags($data['value'],'<a>');
    $email_body .= "<b>{$data['label']}</b> ".$data['value']."\n";
    }
    }else{
    $email_body .= "<b>{$data['label']}</b> - {$data['value']} \n";
    }

    Any suggestions?

    Greetings

    Posted 14 years ago #
  5. yuniar

    Willy,

    Can you send us your modified file please? We'll check it.


    MachForm Founder

    Posted 14 years ago #
  6. Willy
    Member

    Hi Yunair,

    My helper-functions.php is a clean file without any modifications.

    If I make the modification suggested the dash doesn´t disappear.

    I believe the dash comes from entry-functions.php, from line 370,

    $checkbox_content .= '- '.$option_label.'';

    If I remove that dash the dash doesn´t show in the email, without modifying anything else.

    I don´t know if removing that dash will affect anything else except for the email checkbox results.

    What do you think?

    Greetings.

    Posted 14 years ago #

RSS feed for this topic

Reply