Support

Account

Home Forums Front-end Issues Value and Label are the same when var dumping

Helping

Value and Label are the same when var dumping

  • Hey all

    I have an issue with checkboxes, when I echoing both label and value they are displaying the same name.

    for example:

    WIFI-1 : Wi-FI
    TV-1 : TV
    pets-1 : Pets
    Non-Smoking-1 : Non-Smoking
    Iron-1 : Iron
    <?php
    $amenities = get_field('amenities');
    if( $amenities ): ?>
    <ul>
    	<?php foreach( $amenities as $amenity ): ?>
    		<li><span><?php echo $amenity['label']; ?>|<?php echo $amenity['value']; ?></span></li>
    		<pre><?php var_dump($amenity); ?></pre>
    	<?php endforeach; ?>
    </ul>
    <?php endif; ?>

    This is what I get

    Wi-FI|Wi-FI
    array(2) {
      ["value"]=>
      string(5) "Wi-FI"
      ["label"]=>
      string(5) "Wi-FI"
    }
    TV|TV
    array(2) {
      ["value"]=>
      string(2) "TV"
      ["label"]=>
      string(2) "TV"
    }
    Pets|Pets
    array(2) {
      ["value"]=>
      string(4) "Pets"
      ["label"]=>
      string(4) "Pets"
    }
    Non-Smoking|Non-Smoking
    array(2) {
      ["value"]=>
      string(11) "Non-Smoking"
      ["label"]=>
      string(11) "Non-Smoking"
    }
    Iron|Iron
    array(2) {
      ["value"]=>
      string(4) "Iron"
      ["label"]=>
      string(4) "Iron"
    }
    Hair Dryer|Hair Dryer
    array(2) {
      ["value"]=>
      string(10) "Hair Dryer"
      ["label"]=>
      string(10) "Hair Dryer"
    }
    Air Condition|Air Condition
    array(2) {
      ["value"]=>
      string(13) "Air Condition"
      ["label"]=>
      string(13) "Air Condition"
    }
    Netflix|Netflix
    array(2) {
      ["value"]=>
      string(7) "Netflix"
      ["label"]=>
      string(7) "Netflix"
    }
    Fully Equipped Kitchen|Fully Equipped Kitchen
    array(2) {
      ["value"]=>
      string(22) "Fully Equipped Kitchen"
      ["label"]=>
      string(22) "Fully Equipped Kitchen"
    }
    Kitchenette|Kitchenette
    array(2) {
      ["value"]=>
      string(11) "Kitchenette"
      ["label"]=>
      string(11) "Kitchenette"
    }
    Washing Machine|Washing Machine
    array(2) {
      ["value"]=>
      string(15) "Washing Machine"
      ["label"]=>
      string(15) "Washing Machine"
    }
    Nespresso Machine|Nespresso Machine
    array(2) {
      ["value"]=>
      string(17) "Nespresso Machine"
      ["label"]=>
      string(17) "Nespresso Machine"
    }
    
  • I just tried creating a checkbox field with your values and set to return both value and label as an array and it is working as expected.

    What are your field settings?

    What other plugins are you running?

    Have you tried deactivating other plugins or switching themes to see if there is a conflict?

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

You must be logged in to reply to this topic.