• Let me first say: “I know this question is not specific related to ACF Extended” still I’m asking it here because this is an very active support forum and my last resort… ACF support, ACF forum, Stackoverflow… Nothing. And I have to believe my question is not that hard to answer.

    To share and to let everyone see I’m not ‘just asking without trying’:

    How to populate a select field with values of a textarea on an option page:

    function acf_load_color_field_choices( $field ) {
        
        // reset choices
        $field['choices'] = array();
        
        
        // get the textarea value from options page without any formatting
        $choices = get_field('my_select_values', 'option', false);
    
        
        // explode the value so that each line is a new array piece
        $choices = explode("\n", $choices);
    
        
        // remove any unwanted white space
        $choices = array_map('trim', $choices);
    
        
        // loop through array and add to field 'choices'
        if( is_array($choices) ) {
            
            foreach( $choices as $choice ) {
                
                $field['choices'][ $choice ] = $choice;
                
            }
            
        }
        
    
        // return the field
        return $field;
        
    }
    
    add_filter('acf/load_field/name=color', 'acf_load_color_field_choices');

    How to show/hide a field after user makes a selection in a frontend form:

    add_filter('acf/prepare_field/name=booking_time_session_1', 'yl_check_booking_setting_exceptions_session_1');
    function yl_check_booking_setting_exceptions_session_1($field){
        
        // Reset conditions
        // Warning: Conditions set in the UI won't be compatible!
        $conditions = array();
    
        // Creating Base Condition
        $conditions[] = array(
            array(
                'field'     => 'field_5ed4181bd63dc',
                'operator'  => '!=',
                'value'     => '2',
            )
        );
    
        if(have_rows('booking_setting_exceptions', 'booking_settings')):
            while(have_rows('booking_setting_exceptions', 'booking_settings')): the_row();
                
                $date = date_i18n('Ymd', strtotime(get_sub_field('booking_setting_exceptions_date', 'booking_settings')));
                
                // Check: Booking Settings Exceptions Date
                if(empty($date))
                    continue;
                
                // Adding a new AND condition inside Base condition, at the index = 0
                $conditions[0][] = array(
                    'field'     => 'field_5ed4178dd63d7',
                    'operator'  => '!=',
                    'value'     => $date,
                );
            
            endwhile;
        endif;
    
        // Setting the full condition
        $field['conditional_logic'] = $conditions;
         
         return $field;
        
    }

    So what my problem is? Simple.

    I have an ACF option page with some fields:

    Repeater field:
    subfield 1: DATE (datepicker)
    subfield 2: SESSION (select field: Lunch / Dinner)

    Textarea field 1:
    With booking times for lunch

    Textarea field 2:
    With booking times for dinner

    These values should blackout date/session combi’s in a frontend booking form.

    F.I.: In the option page > repeater field > I have > 30th of July + Lunch

    So on the frontend form, when people select booking date 30th of July > The booking TIME field only populates with the DINNER TIMES (because I blackedout Lunch on this date).

    I even tried paid services but that really doesn’t help.

    I’m willing (and will) to pay drinks ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello @yorlinqnl!

    I’m 100% busy with ACF Extended right now, and I don’t have much time right now to develop custom code. However, I might come back here in the future. In the meantime, in case a developer come by, I would suggest you to take screenshots, add notes on it, make a video to show exactly what you want to achieve.

    The feature you’re aking is not as simple as you might think, you probably spent hours on that code, but people can’t read your mind. You will get help more easily if you help developers to help you ??

    Hope it helps!

    Keep it up.

    Regards.

    Thread Starter Dennis Dallau

    (@yorlinqnl)

    Thanks for your reply. I’ve solved it myself in a different (maybe not 100% clean) way but it works great and I’m proud so ??

    SOLVED

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Congratulations! There’s nothing like the feeling to make your own code work ??

    Keep it up!

    Regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Populate select field after user input’ is closed to new replies.