I have added new fields with input type text in the back-end of WordPress, but what about other types? I have tried with no results. Every time I update the property I have to mark with a check again to keep the fields selected. The checkmark is not preserved.
Here is what I’m doing.
<?php $mb->the_field( 'petsallowed' ); ?>
<input type="radio" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value('Yes'); ?>" <?php checked( $mb->get_the_value() ); ?>/>Yes
<input type="radio" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value('No'); ?>" <?php checked( $mb->get_the_value() ); ?>/>No
<input type="radio" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value('Ask'); ?>" <?php checked( $mb->get_the_value() ); ?>/>Ask
What I need/want to do is avoid the input checked
Now I have this:
<?php $mb->the_field( 'pet_yes' ); ?>
<input type="checkbox" name="<?php $mb->the_name(); ?>" value="1" <?php checked( $mb->get_the_value() ); ?>/>
<label>Yes</label>
<?php $mb->the_field( 'pet_no' ); ?>
<input type="checkbox" name="<?php $mb->the_name(); ?>" value="1" <?php checked( $mb->get_the_value() ); ?>/>
<label>No</label>
<?php $mb->the_field( 'pet_ask' ); ?>
<input type="checkbox" name="<?php $mb->the_name(); ?>" value="1" <?php checked( $mb->get_the_value() ); ?>/>
<label>Ask</label>
<input type="radio" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value('Yes'); ?>" <?php checked( $mb->get_the_value(),$mb->the_value('Yes') ); ?>/>Yes
<input type="radio" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value('No'); ?>" <?php checked( $mb->get_the_value(),mb->the_value('No') ); ?>/>No
<input type="radio" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value('Ask'); ?>" <?php checked( $mb->get_the_value(),$mb->the_value('Ask') ); ?>/>Ask
This should work.