Home Forums Add-ons Repeater Field general use of variables in ACF Reply To: general use of variables in ACF

  • 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.