Plugin Author
donmik
(@atallos)
It’s already set to current date or you are saying you want to put current date by default in field ? You cannot remove the day from a datepicker, it’s a html5 field.
Thread Starter
pfrey
(@pattyfresonke)
I want to set the current date in the field, so the user doesn’t have to click anything for today’s date.
Plugin Author
donmik
(@atallos)
Replace the code below of bxcft_edit_render_new_xprofile_field function:
elseif ( bp_get_the_profile_field_type() == 'datepicker' ) {
?>
<div class="input-web">
<label class="label-form <?php if ( bp_get_the_profile_field_is_required() ) : ?>required<?php endif; ?>" for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) { echo __('*', 'bxcft'); } ?></label>
<input type="date" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true" required="required"<?php endif; ?> class="input" value="<?php bp_the_profile_field_edit_value() ?>" />
</div>
<?php
}
By this code:
elseif ( bp_get_the_profile_field_type() == 'datepicker' ) {
if (bp_get_the_profile_field_edit_value() != '')
$value = bp_get_the_profile_field_edit_value();
else
$value = 'put your default date here';
?>
<div class="input-web">
<label class="label-form <?php if ( bp_get_the_profile_field_is_required() ) : ?>required<?php endif; ?>" for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) { echo __('*', 'bxcft'); } ?></label>
<input type="date" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true" required="required"<?php endif; ?> class="input" value="<?php echo $value; ?>" />
</div>
<?php
}
Tell me if this works.
Thread Starter
pfrey
(@pattyfresonke)
Well, I wasn’t really sure what to put in $value = ‘put your default date here’; but I tried date(“j F Y”) and that didn’t seem to do anything to the datepicker
Plugin Author
donmik
(@atallos)
You need to use this format:
date('Y-m-d')
Thread Starter
pfrey
(@pattyfresonke)
Still not seeing a value come into those dropdowns…
Plugin Author
donmik
(@atallos)
I tried it and it works for me. Can I see your web ?
Thread Starter
pfrey
(@pattyfresonke)
I figured out how to get it to work, thanks for all your help!
Plugin Author
donmik
(@atallos)
And how do you get it to work ? It will be helpful to know if anyone has the same problem in the future.
Thanks!
Thread Starter
pfrey
(@pattyfresonke)
It was just a typo on my part.