Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array/callback support (Feature request) #20

Open
ghost opened this issue Oct 4, 2018 · 8 comments
Open

Array/callback support (Feature request) #20

ghost opened this issue Oct 4, 2018 · 8 comments

Comments

@ghost
Copy link

ghost commented Oct 4, 2018

Maybe a nice feature is making the ability to pass in an array with values on which the value of the input filed gets checked. If the value is in the array then the container should show. Whereas now it only accepts one value per field.

It could look like so
screen shot 2018-10-04 at 3 24 55 pm

Or you could even make it a callback.
screen shot 2018-10-04 at 3 32 51 pm

@valentinceaprazaru
Copy link

valentinceaprazaru commented Dec 9, 2018

Having a Iterable field i was able to solve this by updateting the NovaDependencyContainer.php to show:

`

public function resolveForDisplay($resource, $attribute = null)
{
parent::resolveForDisplay($resource, $attribute);

    foreach ($this->meta['dependencies'] as $index => $dependency) {

        if(array_key_exists('notEmpty', $dependency) && ! empty($resource->{$dependency['field']})) {
            $this->meta['dependencies'][$index]['satisfied'] = true;
        }

        if (is_iterable($resource->{$dependency['field']})) {

            $filtered = $resource->{$dependency['field']}->filter(function ($value, $key) use (&$dependency) {

                return $value->id == $dependency['value'];
            });

            if (array_key_exists('value', $dependency) && $filtered->isNotEmpty()) {
                $this->meta['dependencies'][$index]['satisfied'] = true;
            }
        } else {

            if (array_key_exists('value', $dependency) && $dependency['value'] == $resource->{$dependency['field']}) {
                $this->meta['dependencies'][$index]['satisfied'] = true;
            }
        }
    }
}

`

@dtannen
Copy link

dtannen commented Dec 10, 2018

What is the corresponding change to FormField.vue to make this work on the front end also?

@valentinceaprazaru
Copy link

valentinceaprazaru commented Dec 10, 2018 via email

@dtannen
Copy link

dtannen commented Dec 10, 2018

I updated the VUE part and submitted a pull request

@drsdre
Copy link

drsdre commented May 21, 2019

Maybe PullRequest #56 can help as it accepts values in an array.

@wize-wiz wize-wiz added the enhancement New feature or request label Sep 27, 2019
@wize-wiz wize-wiz removed the enhancement New feature or request label Oct 3, 2019
@aedart
Copy link

aedart commented Jul 22, 2020

I hope that this feature request is still active. I too could really use a different mechanism for value comparison.
The most dynamic I can imagine, is by accepting a callback, as @ghost already suggested.

@wize-wiz
Copy link
Contributor

wize-wiz commented Jul 22, 2020

@aedart no it's not active, I'm currently working on different solution. Callback is not possible, this will just not work.

@aedart
Copy link

aedart commented Jul 22, 2020

@wize-wiz, ok. Thanks for your quick reply :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants