whitecube / nova-flexible-content

Flexible Content & Repeater Fields for Laravel Nova
MIT License
790 stars 234 forks source link

Is it possible to make the layout open by default? #107

Open evidencefrank opened 5 years ago

evidencefrank commented 5 years ago

Hi Guys. I have been using this package for quite a while now and its a very good package.

Recently i have been trying to set the layout to 'open' by default but can't seem to find any solution. I have limited the layouts to only four and would want one layout to be open by default without having to click a button.

Any assistance will surely be appreciated.

voidgraphics commented 5 years ago

Hi @evidencefrank, you can call ->collapsed(false) on your flexible field. This will open the layouts. We do not have the ability to open/close layouts individually at this time.

evidencefrank commented 5 years ago

Hi @voidgraphics , thanks for the prompt reply. I had tried the option ->collapsed(false) but nothing seems to be changing. I still have to click the button to open a layout. I'm using this version "whitecube/nova-flexible-content": "^0.1.11".

voidgraphics commented 5 years ago

Strange. From what I remember, they should be collapsed by default indeed, yet on my end they are open by default, which is not normal either. So very inconsistant with what you're describing. But from my tests, the collapsed method works as intended.

I will reopen to further investigate. Do you have any JS errors in the console? Or errors in the Laravel log file? Can you share a more complete code example? Thanks

evidencefrank commented 5 years ago

Hi @voidgraphics

This is the bit of code that i wrote and it is working fine except for the collasped option.

<?php

namespace App\Nova;

use Dukstra\MeetingDatetimepicker\MeetingDatetimepicker;
use Dukstra\MultipleUpload\MultipleUpload;
use Illuminate\Support\Facades\DB;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\Date;
use Laravel\Nova\Fields\ID;
use Illuminate\Http\Request;

use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Trix;
use Laravel\Nova\Http\Requests\NovaRequest;

use Whitecube\NovaFlexibleContent\Flexible;

class Meeting extends Resource
{
    use HasDependencies;

    public function fields(Request $request){

   return [

    Flexible::make('Meeting` Details')
                ->addLayout('Meeting Details', 'wysiwyg', [
                    MeetingDatetimepicker::make('Date & Time', 'date_time')
                        ->startDateTime($this->start_date)
                        ->endDateTime($this->end_date)
                        ->rules(['required']),
                    Text::make('Venue', 'venue')->hideFromIndex(),
                    Trix::make('Notes', 'notes')->hideFromIndex(),
                    MultipleUpload::make('Attachments', 'attachments')
                        ->disk('s3')
                        ->path('storage/meetingAttachments')
                        ->maxSize(2)
                        ->maxFiles(2)
                        ->hideFromDetail(),
                ])//->fullWidth()
                ->limit(4)
                ->button('Add Another Meeting')
                ->collapsed(false)
                ->hideFromDetail()
                ->hideWhenUpdating()
                ->rules(['required']),
       ]
   }
}

I also don't have errors in both the JS console and the Laravel Log file.

toonvandenbos commented 4 years ago

@voidgraphics any news on this issue ? :)

emir commented 4 years ago

@voidgraphics Same here.

JurjenRoels commented 4 years ago

With not having a default Flexible that you can open. This would be a way to have at least not have to click the flexible button. Not working with: v0.2.6