Support

Account

Forum Replies Created

  • I have the same problem, but with Russian language.
    After half of hour looking i found why is it translating:

    foreach( array('label', 'instructions') as $s ) {
    		
    		$field[ $s ] = __($field[ $s ]);
    		
    	}

    in acf_get_valid_field function, wich is called when field is loaded to the metabox or acf form

    Aldought it’s good that field can be translated, but it misses the important parametr – textdomain and less important – context.

    If there could be something like these:

    $field[ $s ] = __($field[ $s ], apply_filters( 'acf/translation/textdomain', 'acf-translation', $field[ $s ], $s ) );

    It would be much more effective and wouldn’t cost so much problems!
    Aldought i’m no shoure that with Code Style Localization or wpml you would be able to find and collect all transatable strings ( becouse they are variables, and variables can’t be writen or readen from gettext ).
    As one of posible solutions threre could be an exit:
    for example add a function wich will check the php file and find the string in it, and if it doasn’t have it, then write new _x( ‘$var’, ‘context’, ‘textdomain’ ); string to it ( that’s the only, known by me, way to achive these ).

  • Found that on field_group creation i can add an logic, so it took me just creating “and current user type == ‘admin’ || current user type == ‘author'” so, no php code eneeded for that, it’s making from the conditional logic fields.

  • I found workaround:

    add_action( 'admin_footer', function() {
    	?>
    	<script type="text/javascript">
    		var tmp_acf_serialize_form = acf.serialize_form;
    		acf.serialize_form = function( $el, prefix ) {
    			var data = tmp_acf_serialize_form( $el, prefix );
    			data['post_id'] = <?php echo get_the_id(); ?>;
    			return data;
    		}
    	</script>
    	<?php
    } );

    and now in add_filter( 'acf/validate_value/... you can use $_REQUEST['post_id'];

    There’s needs to be checked if acf exists in js…

  • Not realy.. I need to compare value if it exists in othere posts and if does then fail the validation, but since we don’t have $post_id i can’t exclude current post to check how many posts there are with meta_value. And if i don’t exclude curent id then when i do validation on new post it doesn’t have a meta_value set and get_posts finds only 1 post and validation is ok, so after validate_value i have 2 pots with same meta_value

    So if someone knows how can we get post_id in validate_value please tell us!

  • Hi,
    No there’s no way u can change it to radio/checkbox becouse it’s hardcoded in render function that type is select.

    Aldought u could apply filters to settings when generating select field but it’s to difficould to track specific field ( for ex. if you don’t know key or prefix ).

    If u want u can try with these filter:
    acf/get_valid_field/type=select to find some specific key wich is only in users field and change type to checkbox or radio

  • This reply has been marked as private.
  • Finaly i found the problem!!

    omg how difficult it’s realised..

    So, as u know i had hidden input in my output ( render_field ) and as i understood it’s errasing is value not changed, so my problem was that wen in js i do $hiden.val( newVal ) the ‘change’ event is not fiered and ACF js files don’t see my input change and do not update value..
    So the solution was:
    $hidden.val( newVal ).trigger( 'change' );
    .trigger( ‘change’ )
    ( i’w been looking for that solution for few days, could be btter expaned in documentatoion how to make own custom fields )

  • I found out that if on edit fields screen i edit only my custom field then the value is not submited, but if i trigger some othere property with it ( for ex. i have Return value ) then my custom field value updates to.
    I.e. if i change only my custom field – nothing, if i change return value and my custom field – my custom field value saves ok.

    Can u please tell me, do u have some check in js or semething like these ?
    may be in php before save_post action u check the variables ?

    becouse in save_post ( your’s ) i get my field without values submited ( if the’r not updated )

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