So I’m banging my head against this… I’m not too experienced with PHP as of yet, someone asked me to edit a WP plugin.
The PHP
foreach ($options['forms'][$form_id]['inputs'] as $id => $input) {
if (!$input['show'])
continue;
$val = '';
if (isset($_POST[$id])){
$val = esc_attr(strip_tags(stripslashes($_POST[$id])));
}else{
if( isset($input['value']) ) $val = esc_attr(strip_tags(stripslashes($input['value'])));
}
$error = ' ';
if (isset($input['error']) && $input['error'])
$error = ' error ';
if($input['type'] != 'hidden')
$content .= "\t".'<div class="sf_input_container_byben"><label class="w2llabel'.$error.$input['type'].'" for="sf_'.$id.'">'.esc_html(stripslashes($input['label'])).':';
if ($input['required'] && $input['type'] != 'hidden')
$content .= ' *';
if($input['type'] != 'hidden')
$content .= '</label>';
if ($input['type'] == 'text') {
$content .= '<input value="'.$val.'" id="sf_'.$id.'" class="w2linput text" name="'.$id.'" type="text"/></div>';
} else if ($input['type'] == 'textarea') {
$content .= '<textarea id="sf_'.$id.'" class="w2linput textarea" name="'.$id.'">'.$val.'</textarea></div>';
} else if ($input['type'] == 'hidden') {
$content .= '<input type="hidden" id="sf_'.$id.'" class="w2linput hidden" name="'.$id.'" value="'.$val.'"></div>';
}
}
Obviously that’s partial.
Everything is outputting as expected, except for the fact that I’m getting a <br /> after each </label> (closing tag). nl2br is NOT in use anywhere in the php file.
What am I missing? I can link to the files directly if more information is needed.
The HTML is being output as:
<div class="sf_input_container_byben">
<label class="w2llabel text" for="sf_first_name">First name: *</label><br />
<input value="" id="sf_first_name" class="w2linput text" name="first_name" type="text"/>
</div>
Not an optimal fix, but I’m running out of time so I just used
display: none;in my CSS to hide<br>elements within the form.Props to Paul for linking me to a forum thread that was covering a separate issue but provided that solution.