Support

Account

Home Forums Front-end Issues Check type of field

Solved

Check type of field

  • I may do a mistake…

    $fields = acf_get_fields('71'); //my field group
    // var_dump( $fields );
    
    $values = get_fields(); 
    
    if( $fields ) { 
    	echo '<table border="1">';
    	foreach ($fields as $field) {
    		$value = $values[$field['name']];
    	    echo '<tr>';
    		echo '<td class="detail-key">' . $field['label'] . '<br/><em>';
    		if ( $field['type'] == 'radio' ) {
    			$field['instructions'];
    		} else {
    			$value;
    		}
    		echo '</em></td>';
    		if ( $value == 'N/E' ) {
    			echo '<td class="detail-value">⨯</td>';
    		} else {
    			echo '<td>&nbsp;</td>';
    		}
    		if ( $value == 'N/A' ) {
    			echo '<td class="detail-value">⨯</td>';
    		} else {
    			echo '<td>&nbsp;</td>';
    		}
    		if ( $value == 'C' ) {
    			echo '<td class="detail-value">⨯</td>';
    		} else {
    			echo '<td>&nbsp;</td>';
    		}
    		if ( $value == 'N/C' ) {
    			echo '<td class="detail-value">⨯</td>';
    		} else {
    			echo '<td>&nbsp;</td>';
    		}
    		echo '</tr>';
    	}
    	echo '</table>';
    }

    Nothing on output where I check the type…
    Many thanks for any help

  • you’re not outputting the values

    
    
    		if ( $field['type'] == 'radio' ) {
    			echo $field['instructions'];
    		} else {
    			echo $value;
    		}
    
  • (;一_一)

    (shame on me)

    OK now the value of message field type doesn’t echo.
    Is it a different approach than just getting the value ?

  • Yes, a message field works differently than other fields. $field['message'] has the message value.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Check type of field’ is closed to new replies.