Comments (13)
Hi @ffranchina
Thanks for the bug report and PR.
Yes, it looks like the date / time picker fields don't respect the 'disabled', 'readonly' or 'required' attributes. I will do some testing and add this into the next version.
Thanks
Elliot
from acf.
Hi guys.
Thanks for prompting me to look into this again.
I've had another look and implemented a fix.
To help test, please edit the file "includes/fields/class-acf-field-date_picker.php" and change the render_field() function on line 92 to:
function render_field( $field ) {
// vars
$hidden_value = '';
$display_value = '';
// format value
if( $field['value'] ) {
$hidden_value = acf_format_date( $field['value'], 'Ymd' );
$display_value = acf_format_date( $field['value'], $field['display_format'] );
}
// elements
$div = array(
'class' => 'acf-date-picker acf-input-wrap',
'data-date_format' => acf_convert_date_to_js($field['display_format']),
'data-first_day' => $field['first_day'],
);
$hidden_input = array(
'id' => $field['id'],
'name' => $field['name'],
'value' => $hidden_value,
);
$text_input = array(
'class' => 'input',
'value' => $display_value,
);
// special attributes
foreach( array( 'readonly', 'disabled', 'required' ) as $k ) {
if( !empty($field[ $k ]) ) {
$hidden_input[ $k ] = $text_input[ $k ] = $k;
}
}
// save_format - compatibility with ACF < 5.0.0
if( !empty($field['save_format']) ) {
// add custom JS save format
$div['data-save_format'] = $field['save_format'];
// revert hidden input value to raw DB value
$hidden_input['value'] = $field['value'];
// remove formatted value (will do this via JS)
$text_input['value'] = '';
}
// html
?>
<div <?php acf_esc_attr_e( $div ); ?>>
<?php acf_hidden_input( $hidden_input ); ?>
<?php acf_text_input( $text_input ); ?>
</div>
<?php
}
Please let me know how you go with this :)
from acf.
@elliotcondon If this can be added to the plugin, that would be great! I was looking for exactly this fix.
from acf.
@elliotcondon no problèm ;)
I try with this code :
foreach( array( 'readonly', 'disabled', 'required' ) as $k ) {
if( !empty($field[ $k ]) ) {
$hidden_input[ $k ] = $k;
}
}
just delete the $text_input[ $k ] in the foreach and it's work fine for me.
If i can help i'm here ;)
from acf.
@Bnjis, your solution seems to have fixed the issue for me temporarily! I'm not sure if it causes any issues but thank you for this! You saved my hide before my client would've noticed this.
from acf.
Great! Thank you :)
Have a nice day!
Francesco
from acf.
Hi @Bnjis
Thanks for the bug report. I have just tested and can confirm the same issue.
I will work on a fix for this today
from acf.
@beezischillin Your welcom ;)
Yes i don't know too for other issues. I think the dev team will fix it soon.
I do an other fix without update plugin code with javascipt if you want :
acf.add_action("load", function($el) {
var $form = $("ACFFORMNAME");
$form.find(".acf-input input.hasDatepicker").attr('required', null)
}
from acf.
@FriendlyWP Thanks. Version 5.8.0-beta3 is now a little behind the latest 5.7.9 and 5.7.10 (planfor today) versions. The next 5.8.0 beta will definitely have this fixed.
from acf.
Did this ever get incorporated?
from acf.
Hi @elliotcondon i think you add a bug in this issue,
When you do this :
// special attributes
foreach( array( 'readonly', 'disabled', 'required' ) as $k ) {
if( !empty($field[ $k ]) ) {
$hidden_input[ $k ] = $text_input[ $k ] = $k;
}
}
You add a "requiered" attribute to a text input.
If this text input is "display none" by a repeater fields or a conditionnal display, you will have an error when you try to save post.
The browser will try to focus in the field but he can not. in this case you need to add a "novalidate" attribute on the form or remove the "requiered" on the text input.
We try and we got this screen :
from acf.
I can confirm this is still happening in 5.8.0-beta3. Required text field inside a Repeater (inside a Flexible Content field set) throws the error, making it impossible to save/publish the page if that FC field wasn't selected /used / filled-out.
from acf.
Please, beware this issue happens also for date_time_picker fields, and the solution is the same one that was applied to date_picker fields on version 5.8.0. In version 5.8.0, it's working on date_picker fields, but not on date_time_picker fields.
And the same goes for fields of type user, they can't be disabled. But with these, it can't be fixed in the same way as the date pickers.
from acf.
Related Issues (20)
- The ACF API integration issue with attachments
- Only Preview mode is available in WP 6.5beta1 HOT 6
- potential infinite loop in acf_get_field_ancestors()
- Block fields now show in the right hand side panel HOT 1
- True/False field fold together and can't be changed/updated HOT 3
- When returning false in acf/load_field or acf/prepare_field multiple warnings occur HOT 1
- ACF post preview and revisions completely broken HOT 8
- WYSIWYG 'visual' tab in sidebar breaks when switching sidebar tabs HOT 1
- WYSIWYG Editor Field: Image element with width and height attributes triggers unsafe HTML error message HOT 4
- filter wysiwyg_tinymce_settings breaking HOT 1
- Front-end form submits itself when closing the wordpress link-edit dialogue
- Nested cloned repeater only works for 1 level
- Gallery - edit image breaks field in block sidebar HOT 1
- ACF 6.3.0 update breaks "No fields assigned" filter with empty string HOT 3
- Can't add ACF licence key HOT 1
- update_field() not working as expected in this scenario HOT 3
- Installing through composer installs incorrect version HOT 5
- Uncaught TypeError: Cannot access offset of type string on string - flexible content HOT 4
- Fix jQuery deprecations HOT 1
- User field stopped showing in GraphQL query
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acf.