MyBB Community Forums
Datetime input in the DefaultForm class - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Development (https://community.mybb.com/forum-161.html)
+--- Forum: Suggestions and Feedback (https://community.mybb.com/forum-199.html)
+--- Thread: Datetime input in the DefaultForm class (/thread-226589.html)



Datetime input in the DefaultForm class - MisterVector - 2020-02-23

There is a method in the DefaultForm class, generate_date_select, which is used to generate a date selection. However, there is no function to generate date + time inputs. In a plugin I'm working on, I created such a function that uses the "date" and "time" inputs.

require_once MYBB_ROOT . "cgdadmin/inc/class_form.php";

/**
 * Workaround for a method that doesn't exist in the DefaultForm class
 */
class ModifiedForm extends DefaultForm {
    function generate_datetime_field($name, $date="", $time="") {
        return "<input type=\"date\" name=\"" . $name . "_date\" id=\"" . $name . "_date\" value=\"" . $date . "\" />
                <input type=\"time\" id=\"" . $name . "_time\" name=\"" . $name . "_time\" value=\"" . $time . "\"";
    }
}


Could something similar be implemented into MyBB?


RE: Datetime input in the DefaultForm class - Omar G. - 2020-02-26

Could be nice as a plugin helper.

Would be nice to implement for the task system and any other place where suitable.