WordPress.org

Ready to get started?Download WordPress

Forums

Form Manager
label tags around checkbox list items (patch) (1 post)

  1. SugarBoy
    Member
    Posted 2 years ago #

    The labels within a checkbox list are currently (as of WP FM 1.6.35) placed right after the corresponding <input> elements as blank text nodes. This makes it rather inconvenient to access them through CSS or JS.
    I suggest to enclose them in HTML <label> tags, according to the following scheme:

    <form>
    <input type="checkbox" id="custom_list-xxxx"><label for="custom_list-xxxx">Label associated with checkbox</label>
    ...
    </form>

    Here's a patch to be applied to wordpress-form-manager/formelements/formelements.php:

    --- formelements.php	2012-05-25 17:42:51.000000000 +0200
    +++ formelements.modified.php	2012-05-25 17:57:56.571064600 +0200
    @@ -90,7 +90,7 @@
     	if(!(isset($elementDef['options']) && is_array($elementDef['options']))) return "";
     	$arr=array();
     	foreach($elementDef['options'] as $k=>$v){
    -		$arr[] = "<input type=\"checkbox\" ".fe_getAttributeString($elementDef['attributes'])." id=\"".htmlspecialchars($k)."\" name=\"".htmlspecialchars($k)."\" ".($vals[$k]?'checked':'')."/>  ".htmlspecialchars($v)."";
    +		$arr[] = "<input type=\"checkbox\" ".fe_getAttributeString($elementDef['attributes'])." id=\"".htmlspecialchars($k)."\" name=\"".htmlspecialchars($k)."\" ".($vals[$k]?'checked':'')."/><label for=\"".htmlspecialchars($k)."\">".htmlspecialchars($v)."</label>";
     	}
     	$str = implode($elementDef['separator'],$arr);
     	return $str;

    http://wordpress.org/extend/plugins/wordpress-form-manager/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic