Support

Account

Forum Replies Created

  • hi,

    as i said, it is not a real issue. i can not provide any code, cause it is just too special and complex to show it. its clear that inside acf everything is fine, cause all variables or array values (should) exist.

    it is just a bit “dirty” code, that an if($variable) statement is just called without isset(). since php 5.x (i’m not sure since which version), php throws an error, if you do not write if(isset($variable))…

    as i said, using acf repeater field as proposed by the author will NEVER throw this error, cause every possible variable or array value will exist.

    ok, just a snippet:
    i have my own class, just nearly the same like acf_field_repeaters:

    class acf_field_my_own_repeaters extends acf_field

    and within this class i have the same functions like in the original acf repeater class, but not just as a copy-paste. i directly “include” the original acf repeater class function, but “send” my additionally field settings to the original class-function, e.g. the “sub_fields”:

    function load_field( $field ) {
    	$field = $this->my_sub_fields($field);
    	
    	return acf_field_repeater::load_field( $field );
    }

    my_sub_fields() is a new class function, that just gets all the configuration from a configuration file, that i create. this allows me to set up everything fast and easy in a file instead of using the backend acf configuration. the original way of using acf is nice for small input masks, but i have VERY complex input masks and i would need MUCH MORE time to set up my input masks. this works much faster with my configuration file.

    my – very own – problem is, that i need to set up EVERY variable, that could be used by acf. if you would use isset(), this would be not necessary.

    as i said – it is not a real issue and a very own problem of mine, but i think, that the acf code would be cleaner if a statement like if($variable) would be written like if(isset($variable)).
    it will make NO DIFFERENCE for the functionality, but it is the correct way to do an if statement in PHP.

  • at the end, it is just a nice to have for me, but i think this coding for an “IF..” is old stuff, that could be more clean.

  • hi,

    as i said, it is not a real issue. i developed my own field type and in it i use the real acf pro field “repeater”. it is just, cause i can do all configurations directly in my config files and do not need to click through the acf setup pages. it just save A LOT of time for me.

    ofcourse i try to set up as few variables as i can to reduce my config files.

    newer versions of php throw errors, if a variable or an array value is not existing. its a common way to ask for the existing of a variable by using “isset()”. the way it is done often in the acf code is an old way, that php in newer version do not like.

    just turn on all error_reporting (EALL) and write something like:

    if( $variable) {
     ....
    }

    you should see an error output.

  • hi elliot,

    thanks for this. it “almost” works. it has to be:

    add_action('acf/include_field_types', 'my_include_field_types', 20);

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