This seems to be the answer across multiple topic in acf forums ;(
Say we want to add an ID – its easy to attach a field
into the link dialog box. But the data isn’t being saved
with acf.
$('#link-options').append(
<div>
<div className=”flex flex-row”>
<label htmlFor=”wpse_link_class col-6″>
<span>Button Type</span>
<select name=”wpse-link-class” id=”wpse_link_class”>
<option value=”normal”>normal</option>
<option value=”btn btn-yellow”>Yellow button</option>
<option value=”btn btn-yellow btn-lg”>Yellow button (big)</option>
<option value=”btn btn-outline”>Outline button</option>
<option value=”btn btn-outline btn-lg”>Outline button (big)</option>
</select>
</label>
</div>
<label for=”sgx_custom_link_id”>
<span>Link ID</span>
<input type=”text” name=”sgx_custom_link_id” id=”sgx_custom_link_id” />
</label>
</div>
`);
wpLink.getAttrs = function() {
wpLink.correctURL();
return {
class: $( ‘#wpse_link_class’ ).val(),
href: $.trim( $( ‘#wp-link-url’ ).val() ),
target: $( ‘#wp-link-target’ ).prop( ‘checked’ ) ? ‘_blank’ : ”,
id: $( ‘#sgx_custom_link_id’ ).val() // this doesn’t work.
};
}`
This is an issue that drove my crazy twice. took me a second to remember,
the thing is that some type of widget structure is the problem
i have to change 2 things.
1. your right. we must return an array inside the update
2. we need to register the widget inside the __construct() (which is inside the class)
// construct inside the class
public function __construct() {
$widget_ops = array(
'classname' => 'cmenu_widget',
'description' => 'Custom menu widget built with ACF Pro',
);
parent::__construct( 'acf_cmenu_widget', 'ACF Custom Menu Widget', $widget_ops );
add_action( 'widgets_init', function() {
register_widget( 'AcfCMenuWIdget' );
});
}
and after that class just call it like so
$someClassVar = new someClassName();
OMG thank you man (Really!) appreciate you ❤️🙏❤️🙏❤️
i spent 2 days on this shit.
ACF staff should really show a popup / a quick post notifying in such cases
we are wasting a lot of time and grow white hairs trying to track such things
No advance on that issue?
i tried this
add_filter('acf/prepare_field/type=tab', 'sagive_validate_extra_tabclass', 10);
function sagive_validate_extra_tabclass( $field ){
if( !empty($field['tabclass']) ) {
$field['class'] = 'some-class';
$field['wrapper']['class'] = 'some-class';
}
return $field;
}
Doesnt work (at least on the tab element)… which is where i need it.
The parent is not related… its the group. So u’ might mean making that cloned a group inside the element. But that’s a given and not the solution.
Anyhow thanks. I guess there is no solution.
acf should save the ref for the original field but I guess its
an optimization issue or something.
Maybe I would find a way to auto-tick that save as a group so as to at least have a better flow when working.
I would love to do that (only change the display) – that’s even easier.
However… as it seems (example: https://pastebin.com/Bw1dBbAt)
the information meaning the original field label isn’t included in the
cloned field data. is there another hook/filter way to do this?
If you think about it
making a global field which u can use across page templates / locations
needs a ‘relative to location’ title… so this is not a weird idea.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.