# profile-builder/2.0.4/assets/lib/wck-api/fields/radio.php

User Profile Builder – Beautiful User Registration Forms, User Profiles &amp; User Role Editor, version 2.0.4. 39 lines.

- Page: https://pluginprobe.com/plugins/profile-builder/2.0.4/code/assets/lib/wck-api/fields/radio.php
- Raw: https://pluginprobe.com/plugins/profile-builder/2.0.4/raw/assets/lib/wck-api/fields/radio.php
- Modified: 2014-10-21T13:22:44+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/profile-builder/2.0.4/code/assets/lib/wck-api/fields/radio.php#L10-L20`.

```php
<?php
 /* @param string $meta Meta name.	 
 * @param array $details Contains the details for the field.	 
 * @param string $value Contains input value;
 * @param string $context Context where the function is used. Depending on it some actions are preformed.;
 * @return string $element input element html string. */

if( !empty( $details['options'] ) ){
	$element .= '<div class="wck-radiobuttons">';
	foreach( $details['options'] as $option ){
		$found = false;
		
		$values = explode( ', ', $value );						
		if( strpos( $option, '%' ) === false  ){
			$label = $option;
			$value_attr = $option;
			if ( in_array( $option, $values ) ) 
				$found = true;
		}
		else{
			$option_parts = explode( '%', $option );
			if( !empty( $option_parts ) ){
				if( empty( $option_parts[0] ) && count( $option_parts ) == 3 ){
					$label = $option_parts[1];
					$value_attr = $option_parts[2];
					if ( in_array( $option_parts[2], $values ) ) 
						$found = true;
				}
			}
		}
				
		$element .= '<div><label><input type="radio" name="'. esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $details['title'], $details ) ) .'" id="';
		if( !empty( $frontend_prefix ) )
			$element .=	$frontend_prefix; 
		$element .= esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $details['title'] . '_' . $value_attr ) ) .'" value="'. esc_attr( $value_attr ) .'"  '. checked( $found, true, false ) .'class="mb-radio mb-field" />'. esc_html( $label ) .'</label></div>';
	}
	$element .= '</div>';
}
?>
```
