Is there a way to programmatically set the default value for fields on the insert form? For example, I’d like to default a date field to the current date. I looked through the filters and couldn’t find one that does that but I may be missing it
You can use Placeholders like predifined value in filters if your table is MySQL based. When you what to use it you need to set Filter type to text.
Unfortunately at the moment is not possible to set current day in filter predefined value.
You can achieve this with SQL query like this
SELECT *
FROM table_name
WHERE table_name.`name_of_column_that_contain_date` = CURDATE()
Like this will be shown only rows with current day.
If you not use queries, you can also filter the table with Conditional formatting for that column where is available %TODAY% placeholder. You have to set rules like this (attachment 1) where you will set two rules one that is less than %TODAY% and second that is greater than %TODAY% and set row class for example hide (like in example)
Then you have to make that class in Custom wpDataTables CSS under the "Custom JS AND CSS" in main settings of wpdatatables.(attachment 2)
Thanks for the reply! Sorry for the confusion, I was actually talking about setting the default value on the form that is used to add a new record. When I mentioned filters, I was talking about WordPress hooks. I looked through the list here https://wpdatatables.com/documentation/information-for-developers/filters/ and couldn't see any that would let me set a default value for a field when adding a new record.
Is there a way to programmatically set the default value for fields on the insert form? For example, I’d like to default a date field to the current date. I looked through the filters and couldn’t find one that does that but I may be missing it
Thanks,
Carl
Hi Carl,
Thank you for your purchase.
You can use Placeholders like predifined value in filters if your table is MySQL based. When you what to use it you need to set Filter type to text.
Unfortunately at the moment is not possible to set current day in filter predefined value.
You can achieve this with SQL query like this
Like this will be shown only rows with current day.
If you not use queries, you can also filter the table with Conditional formatting for that column where is available %TODAY% placeholder. You have to set rules like this (attachment 1) where you will set two rules one that is less than %TODAY% and second that is greater than %TODAY% and set row class for example hide (like in example)
Then you have to make that class in Custom wpDataTables CSS under the "Custom JS AND CSS" in main settings of wpdatatables.(attachment 2)
Like this will be shown data only for current date.
Best regards.
Kind Regards,
Isidora Markovic
wpDataTables: FAQ | Facebook | Twitter | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Amelia demo sites | Docs
You can try our wpDataTables add-ons before purchase on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables
Thanks for the reply! Sorry for the confusion, I was actually talking about setting the default value on the form that is used to add a new record. When I mentioned filters, I was talking about WordPress hooks. I looked through the list here https://wpdatatables.com/documentation/information-for-developers/filters/ and couldn't see any that would let me set a default value for a field when adding a new record.
Thanks!
Carl
Hi Carl,
You can try with this filter.
This filter is applied to the column's metadata returned from the DB.
$columnsMetadata contain all data from column settings and also default_value which you can modify.
Best regards.
Kind Regards,
Isidora Markovic
wpDataTables: FAQ | Facebook | Twitter | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Amelia demo sites | Docs
You can try our wpDataTables add-ons before purchase on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables
Thanks! That's exactly what I needed, and it worked perfectly. I appreciate the advice.
Carl
Hi Carl,
You are welcome. Glad that we help you.
If you have any more issues or questions feel free to open a new ticket, we will gladly help.
We'd greatly appreciate it if you could take a minute and leave a Review on CodeCanyon on this link. Thanks!
Best regards.
Kind Regards,
Isidora Markovic
wpDataTables: FAQ | Facebook | Twitter | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Amelia demo sites | Docs
You can try our wpDataTables add-ons before purchase on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables
Certainly! I just submitted my review. We're loving to power of wpDataTables and appreciate your support.
Thanks,
Carl
Hi Carl,
Thank you so much for great review. It means a lot to us.
Have a nice day.
Best regards.
Kind Regards,
Isidora Markovic
wpDataTables: FAQ | Facebook | Twitter | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Amelia demo sites | Docs
You can try our wpDataTables add-ons before purchase on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables