These are chat archives for WebDevStudios/CMB2

29th
Jun 2016
Dev_NIX
@DevNIX
Jun 29 2016 07:56
Hi! I have a doubt
I'm currently displaying a select field with some options
I would like to hide some options conditionally of the values of other entry already in the database,
Is there a non crazy way to do this?
I've just discovered this library and I'm enjoying it as hell. I come from using a couple of times ACF+Pods because it's the way my company works, and this library gives me a lot of flexibility, plugin-free way of work, and awesome geekness :D
Leon Francis Shelhamer
@twoelevenjay
Jun 29 2016 08:36
What is the data you want to base the condition on? Is it relavant to the mentioned select field?
@DevNIX ^^^
Dev_NIX
@DevNIX
Jun 29 2016 08:37
@twoelevenjay I have a datepicker, and a select with then options "Morning" and "Evening"
I would like to check if there is another post with the same day, and check the select value
if it's stored "Evening", I should show block it and show only "Morning"
I'm guessing I will need ajax, check it and disable the option dinamically right?
Leon Francis Shelhamer
@twoelevenjay
Jun 29 2016 08:41
I like to show / hide
with JS so AJAX would work for me.
Dev_NIX
@DevNIX
Jun 29 2016 08:42
the thing now is to guess how to create the AJAX endpoint
Leon Francis Shelhamer
@twoelevenjay
Jun 29 2016 08:43
I have an instance where I do this but for me it neede to show hide based on the cmb2-row div. so I added classes to this with the filter hook
Dev_NIX
@DevNIX
Jun 29 2016 08:43
I have an idea of how to do it the Wordpress way, afaik there is not an CMB2 way
Leon Francis Shelhamer
@twoelevenjay
Jun 29 2016 08:43
cmb2_row_classes
For mine the condition is based on a select field only, so I don't have to do an ajax call. But you can look at my code on how to add classes to the field rows and the... JS I used to show hide based on those rows.
Dev_NIX
@DevNIX
Jun 29 2016 08:52
@twoelevenjay TY dude!
Leon Francis Shelhamer
@twoelevenjay
Jun 29 2016 08:54
You're welcome.
Dev_NIX
@DevNIX
Jun 29 2016 09:30
Oh, I have one more question!
I would like to validate fields with very common cases
I don't find anything about properties like "mandatory"
(or email)
Justin Sternberg
@jtsternberg
Jun 29 2016 13:00
@DevNIX with the options_cb, you can do all that checking/logic without JS/ajax
On that same page, look for "attributes"
Which show how to add a "required" attribute
Dev_NIX
@DevNIX
Jun 29 2016 14:26
this is awesome, I didn't found that!
I'm using origgami/CMB2-grid to create an alternative, more compact distribution
looking at the example I can see
'attributes'  => array(
   'rows'        => 3,
)
Is there any big difference? Would you recommend me to use this instead an external library?
@jtsternberg ^ :smile:
Justin Sternberg
@jtsternberg
Jun 29 2016 16:11
@DevNIX the 'rows' => 3, in the example would be to add a "rows" attribute with a value of "3", for something like a textarea. It has nothing to do with cmb2-grid. And i've not used CMB2-Grid, but looks nice.
Dev_NIX
@DevNIX
Jun 29 2016 16:17
@jtsternberg oh oh oh, got it!
Justin Sternberg
@jtsternberg
Jun 29 2016 16:17
:thumbsup:
Dev_NIX
@DevNIX
Jun 29 2016 16:17
My experience with CMB2-Grid is great right now
Thank you so much!
Justin Sternberg
@jtsternberg
Jun 29 2016 16:17
Awesome! Would love to see a screenshot when you're done
Or even a tutorial for others to learn how to use ;)
Dev_NIX
@DevNIX
Jun 29 2016 16:18
I would love to get some time for it. I will try :)
Justin Sternberg
@jtsternberg
Jun 29 2016 16:18
:thumbsup:
Dev_NIX
@DevNIX
Jun 29 2016 16:19
Just one more little thing
@jtsternberg I've checked out my frontend and I am getting a Fatal error: Class 'Cmb2Grid\Grid\Cmb2Grid' not found in /var/www/iteaf/wp-content/plugins/unidad-movil/includes/class-ubicaciones-unidad-movil.php on line 153
But the autoinclude is working perfectly on the admin, and the post type is fully functional
I'm using a generator-plugin-wp generated project
did you heard of a similar problem before? I have any clues about this right now...
Justin Sternberg
@jtsternberg
Jun 29 2016 16:22
Sorry, CMB2-Grid isn't my thing, so i'm not sure. :) Might open an issue on that repo.
Dev_NIX
@DevNIX
Jun 29 2016 16:23
I'ts an autoloader problem afaik
Justin Sternberg
@jtsternberg
Jun 29 2016 16:23
Then the issue may need to be opened on the generator-plugin-wp repo.
Dev_NIX
@DevNIX
Jun 29 2016 16:24
Okay