-
Notifications
You must be signed in to change notification settings - Fork 37
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
Does this package support fields with existing values? #48
Comments
It should work on all create/update/detail views, can you post some example of the code you wrote? perhaps you forgot to add the |
Thanks. I have included the trait. I'm using Nova 3.15.0 & laravel 8.14.0 I've changed my code to illustrate the point but I'm testing with this code and still having the issue... I have a panel with some fields that I only want the user to fill if the model is being exported. In my fields array...
The Textarea outside of the ConditionalContainer is being populated with its value from the database but the textarea inside the container is not. See screenshot. On the detail view, the second textarea is not displayed at all... Any suggestions? |
I think the issue is using the Panel. can you try without the panel to see if it works? |
I tried taking the fields out of the panel but it made no difference. So, I played around a bit more and I think I worked out the problem. I have to apologise because I oversimplified the code above and hid the issue. I'm trying to use fields from a related resource, so the code should have been...
Having played around a bit more, I'm finding that if I use a field on the model to control the condition, the conditional fields do get populated. It was because I was using a related field 'affiliate->export' that it was breaking the field population. |
I see, yeah $map = ['propertyA', 'propertyB', 'affiliate->export'];
$yourRealModelData = [ 'propertyA' => 1, 'propertyB' => 2, 'affiliate' => [ 'export' => true ] ]; so it cant find $yourRealModelData['affiliate->export'] that's they the item is always "hidden" because it always evaluates to false |
Understood. I've been trying to find a work around and getting some strange results. First I tried using a simple fillUsing / resolveUsing pair, like this...
But the field values still didn't get populated. So, then I moved the logic into the model. In nova...
In the model class...
This also didn't work. To be clear, the fields are being shown / hidden as expected but the field values are not being populated. It's very strange because if I use a boolean value from the resource model as the condition, the conditional field values are populated correctly. So, the problem appears to be when the condition is from a related table, even when I try to camouflage that fact using the techniques above. |
Im having almost the same problem. In my case the ConditionalPanel fields do not not have values when in edit mode and are completely hidden when in view mode. Their conditon is based on a ComputedField (eg getIsActiveAttribute) in the Model |
same problem( |
@folyjon Hey, I just started to use the package and find the same problem. Did you find a solution? |
Hi, just playing with this and I'm a bit confused.
Toggling field display depending on the value of another field is working perfectly but the fields which are being conditionally displayed are not being populated with their values from the database.
Not sure if I'm doing something wrong, or if this behavior is expected? Is the package designed to be used in a create scenario but not for updates?
Also, does it work on the detail view? Clearly not dynamically but for example, if 'exported' is set to true, display some extra fields: 'export_date', etc...
Thanks
The text was updated successfully, but these errors were encountered: