reduxframework / redux-framework

Redux is a simple, truly extensible options framework for WordPress themes and plugins!
http://redux.io
Other
1.73k stars 582 forks source link

Required based on sorter choices #2594

Closed alexmoss closed 9 years ago

alexmoss commented 9 years ago

Hi there,

Further to a thread on SO (http://stackoverflow.com/questions/22672922/how-to-use-required-argument-in-redux-framework-based-on-checkbox-sortable), I want to see if this can also be done within the homepage sorter input? So, an example sorter field would be:

array(
                'id'       => 'opt-homepage-layout-2',
                'type'     => 'sorter',
                'title'    => 'Homepage Layout Manager',
                'desc'     => 'Organize how you want the layout to appear on the homepage',
                'compiler' => 'true',
                'options'  => array(
                    'enabled'  => array(
                        'staticpage' => 'Static Page',
                        'services'   => 'Services'
                    ),
                    'disabled' => array(
                        'highlights' => 'Highlights',
                        'slider'     => 'Slider',
                    ),
                ),
            ),

I then want the next option to appear if 'highlights' is moved to enabled. How can I do this?

dovy commented 9 years ago

Umm, Tinker with the arrays? I don't think this is supported. @kprovance can you chime in here?

kprovance commented 9 years ago

If the 'contains' evaluator doesn't work, then no, it isn't supported. I believe with options that are more than two levels deep aren't processed by required (ie - opt_name[sorter-id][enabled][item]. That would take some intense rewriting of required.

alexmoss commented 9 years ago

Even here, using the contains argument shows nothing. Look at this line:

'required' => array('opt-homepage-layout-2','contains','highlights'),

Here, surely this would mean that the input would show regardless of whether 'highlights' was enabled or disabled as it will always be contained within it. Nothing I have tried works. Even these lines don't work:

'required' => array('opt-homepage-layout-2','contains','enabled'), 'required' => array('opt-homepage-layout-2','contains','1'), 'required' => array('opt-homepage-layout-2','contains','options'),

kprovance commented 9 years ago

I've already explained that it's not supposed, and that the amount of work to include compatibility for sorter is more than anyone is willing to donate for. I'm sorry that's where we are now. Blame other devs who didn't want to donate for our work. The project is open source, you are free to fork the project and implement your own solution. If it works and doesn't break other compatibility or backward compatibility, we can add it and credit you.

That are the only two options are present.

alexmoss commented 9 years ago

Of course, wasn't asking for you to build this specifically but perhaps someone had used a 'contains' argument successfully here. If required can't be used, do people generally just have the sorter, then show the options for each element regardless of whether it is disabled or not?

Thanks again

dovy commented 9 years ago

You can code it in your PHP, or do you own custom modifying of your config file before Redux runs and get the same effect. ;)