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

Conditional Container not showing in detail view page #52

Open
matteobreschig opened this issue Jan 6, 2021 · 8 comments
Open

Conditional Container not showing in detail view page #52

matteobreschig opened this issue Jan 6, 2021 · 8 comments

Comments

@matteobreschig
Copy link

Hi and thanks for the great package.
I noticed that if I use a conditional container inside a panel I can't see the fields inside the container in the view page.
No problems instead in the edit page, and no problem in the view page if I put the fields outside the container.
Someone has the same problem?
Thanks.

@ghost
Copy link

ghost commented Mar 4, 2021

I'm also curious about this. Conditional fields are not shown on the index or detail views in Nova.

@milewski
Copy link
Member

milewski commented Mar 5, 2021

I'm also curious about this. Conditional fields are not shown on the index or detail views in Nova.

That is because you could have multiple records, where each display a different field type for example:

Name | Age | Gender | Something else ....

ID=1 Text | Text | Select | Boolean
ID=2 Select | Boolean | Text | Text
....

this would cause the table to be very messy... as each column on each row could represent a completely different thing.. or even worse .. some rows could have more columns than others.. due that conditional container allows you to add any arbritary amount of fields within it...

@mnsuccess
Copy link

Conditional Container not showing in detail view page getting same issue

@milewski
Copy link
Member

milewski commented Dec 8, 2021

Conditional Container not showing in detail view page getting same issue

You probably forgot to include the HasConditionalContainer that is necessary to render the content correctly on the details page

@mnsuccess
Copy link

Conditional Container not showing in detail view page getting same issue

You probably forgot to include the HasConditionalContainer that is necessary to render the content correctly on the details page

I had the trait in my Resource Class
With use HasConditionalContainer and I imported the trait
Still getting the same issue

@milewski
Copy link
Member

milewski commented Dec 8, 2021

Can you show some sample code of what you are doing? maybe the fields are within a panel (which does not work) ?

@mnsuccess
Copy link

Can you show some sample code of what you are doing? maybe the fields are within a panel (which does not work) ?

public function fields(Request $request)
    {
        return [

           RoleSelect::make('Role', 'roles')
                          ->rules('required'),
          
          ConditionalContainer::make([
                          Heading::make('<h1 class="mb-3 text-2xl font-normal text-90">Transporter Information</h1>')->asHtml(),
                          
                          Text::make('Licence Number','transporter_licence_nr')
                          ->sortable()
                          ->rules('required', 'max:255')->hideFromIndex(),
              
          
                      ])->if('roles = Transporter'),


];
    }

@milewski
Copy link
Member

milewski commented Dec 8, 2021

I think the issue is that you are using = instead of == or ===...

Or other possible issue I can think of:

  • RoleSelect is not returning the correct value Transporter when being accessed.. you can debug this by dd($this) and check that value it holds...
  • Maybe the value is being stored as transporter instead of Transporter ?

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

3 participants