• Resolved kdett

    (@kdett)


    Hello,
    first of all: I am delighted with the plugin and the documentation.
    Despite the good documentation, I couldn’t find out how to preset the current date in the date picker field. Can anyone give me a tip?

    Best regards

    Klaus

Viewing 1 replies (of 1 total)
  • Thread Starter kdett

    (@kdett)

    Hello,
    I think I have found a solution. The following code works in my block:

    add_filter('lzb/prepare_block_attribute', 
      function ($attribute_data, $control, $controls, $k, $block) {
    
        // Change default value for custom control "today"
        if ($control && isset($control['type']))
        {
            if ($control['type'] === 'date_time' &&
                $control['name'] == 'today')
            {
                $attribute_data['default'] = date("Y-m-d");
                // $attribute_data['default'] = date('c');  
                //                  in case of date + time
    
                return $attribute_data;
            }
        }
    
        return $attribute_data;
    },         10, 5);
Viewing 1 replies (of 1 total)
  • The topic ‘Preset the current date in the date picker field’ is closed to new replies.