https://twill.io logo
Join Discord
Powered by
# ❓questions
  • u

    uwascan

    10/18/2022, 8:25 PM
    I tried this
    Copy code
    @formField('checkbox', [
            'name' => 'vertical_article',
            'label' => 'Vertical Story'
        ])
    
        @formConnectedFields([
            'fieldName' => 'vertical_article',
            'fieldValues' => true,
            'renderForBlocks' => true,
        ])
            @formField('medias', [
            'name' => 'vertical_image',
            'label' => 'Vertical Image',
        ])
        @endformConnectedFields
    now I have a blank page. Not a single field is showing.
  • i

    ifox

    10/18/2022, 8:25 PM
    are you in a block?
  • i

    ifox

    10/18/2022, 8:26 PM
    if not, you need to use false in
    renderForBlocks
  • u

    uwascan

    10/18/2022, 8:29 PM
    That was it. Love you my friend. I sure need a break.
  • u

    uwascan

    10/18/2022, 11:22 PM
    I have a Contact Messages Module that I want to be a readonly module. This Module is meant to show records created from the frontend contact page. I have the following in my ModuleController.
    Copy code
    protected $indexOptions = [
            'edit' => false,
            'delete' => false,
            'create' => false,
            'publish' => false,
            'reorder' => false,
            'permalink' => false,
            'bulkPublish' => false,
            'skipCreateModal' => false,
        ];
    The records show up but I cant click to view the details in a readonly form. So how to I create a readonly view for module record like the I just described? Is it possible to link each record to a custom page or modal for display?
  • i

    ifox

    10/18/2022, 11:26 PM
    you can keep edit and use the readonly parameter on your form fields, or you can override the edit controller action to show a custom view
  • u

    uwascan

    10/18/2022, 11:32 PM
    Sweet. Is it possible to add a custom command (via a button) to the readonly edit form to show a custom modal to send a reply email? Is the Twill Modal reusable in this context?
  • i

    ifox

    10/18/2022, 11:33 PM
    yes. by working directly with Twill's Vue components
  • b

    BA7YA

    10/19/2022, 10:01 AM
    Do you have any ideas for it?)
  • k

    kalle

    10/19/2022, 1:01 PM
    Answering question with a question in this case will not lead you anywhere. You have to present your idea.
  • d

    dedli

    10/19/2022, 1:03 PM
    Hi guys. I have multi language project on twill with scout and meilisearch. I create separate index item for pages for all languages. I create artisan command. And everything index correct.
    Copy code
    public function handle()
        {
            $client = new Client(config('scout.meilisearch.host'), config('scout.meilisearch.key'));
            $model = 'App\Models\Product';
            foreach (LaravelLocalization::getSupportedLocales() as $localeCode => $properties){
                app()->setLocale($localeCode);
                    $this->call('scout:import', [
                        'model' => $model
                    ]);
                $client->index(app($model)->searchableAs())->updateSearchableAttributes([
                    'title'
                ]);
                $this->info('Updated searchable attributes...');
                $client->index(app($model)->searchableAs())->updateFilterableAttributes([
                    'lang', 'category_id', 'filter_values'
                ]);
                $this->info('Updated filterable attributes...');
            }
            app()->setLocale(config('twill.locale'));
    }
  • d

    dedli

    10/19/2022, 1:03 PM
    In my model I have functions
    Copy code
    public function toSearchableArray()
        {
            return [
                'primary_id' => $this->id,
                'title' => $this->translate(app()->getLocale())->title,
                'slug' => $this->slug,
                'lang' => app()->getLocale(),
                'lang_id' => $this->translate(app()->getLocale())->id,
                'characteristics' => $this->characteristicValues()->get()->map(function ($value){
                    return ['characteristic'=>$value->getRelated('characteristics')[0]->title, 'characteristic_value'=>$value->title];
                })->toArray(),
                'filter_values' => $this->getRelated('filterValues')->map(function ($item){
                    return ['filter'=>$item->filter->slug, 'filter_value'=>$item->slug];
                })->toArray()
            ];
    }
    In my repository I have function
    Copy code
    public function afterSave($object, $fields)
        {
            $this->updateRepeater($object, $fields, 'characteristicValues', 'CharacteristicValue', 'characteristic_values');
            parent::afterSave($object, $fields);
            foreach (LaravelLocalization::getSupportedLocales() as $localeCode => $properties) {
                LaravelLocalization::setLocale($localeCode);
            $client = new Client(config('scout.meilisearch.host'), config('scout.meilisearch.key'));
            $client->updateIndex(app('\\' . get_class($this->model))->searchableAs(), ['primaryKey' => 'lang_id']);
            }
            LaravelLocalization::setLocale(config('twill.locale'));
            app()->setLocale(config('twill.locale'));
        }
    My problem: I should update all languages indexes after save. I try to change locale and do it, but it update only main language. Is any idea how can I do it? I think independent on I use setLocale method my model still works only with main language (отредактировано)
  • b

    BA7YA

    10/19/2022, 1:16 PM
    My idea is pass some data/variables to repeater when Im including it , and use this data in repeater
    Copy code
    @formField('repeater', [
        'type' => 'test_repeater',
        'max' => 2
    ])
  • i

    ifox

    10/19/2022, 2:17 PM
    Thanks, that explains better what you're trying to do, I thought you were looking for conditional fields between a block and its repeaters which is not possible.
  • i

    ifox

    10/19/2022, 2:18 PM
    For this you will need to access or inject the data directly in the repeater file
  • i

    ifox

    10/19/2022, 2:18 PM
    using a helper/service from the blade file or using a view composer in a service provider
  • i

    ifox

    10/19/2022, 2:19 PM
    @dedli Can you please repost this in #1029411044516438110? I will answer there
  • d

    dedli

    10/19/2022, 2:28 PM
    Thanks a lot, just create
  • c

    ckmirafss

    10/19/2022, 10:29 PM
    Hi, how to prevent title duplication?
  • i

    ifox

    10/19/2022, 10:57 PM
    Hi @ckmirafss add a
    unique
    validation rule to r`ulesForCreate` on your module's form request class
  • i

    ifox

    10/19/2022, 10:59 PM
    fwiw title duplication is ok if you use slugs since they do get deduplicated automatically
  • i

    ifox

    10/19/2022, 10:59 PM
    but I can see the use case for unique titles, still
  • p

    PabMai

    10/20/2022, 12:58 PM
    Hi, I'm discovering twill and I wonder if I can use VueJs 3 or React in the frontend in the same laravel project as the inertia package
  • i

    ifox

    10/20/2022, 1:03 PM
    Hi @PabMai for sure, you can use anything you want in front of Twill
  • d

    dakaalim

    10/20/2022, 10:21 PM
    Thankyou
  • d

    dakaalim

    10/20/2022, 10:44 PM
    We getting a table editor in twill 3? is it a table editor for adding a removing fields on modules or a frontend css table?
  • c

    ckmirafss

    10/20/2022, 10:48 PM
    Thanks @ifox ! It worked.
  • i

    ifox

    10/20/2022, 10:56 PM
    not sure what you mean? The listing table of module records in the CMS is fully controllable through a fluent API in the controller in twill 3. Things that you are now doing with the $indexColumns array, objectified.
  • i

    ifox

    10/20/2022, 10:58 PM
    https://github.com/area17/twill/blob/3.x/docs/src/crud-modules/tables.md
  • d

    dakaalim

    10/20/2022, 11:40 PM
    ohhhhh
1...418419420...484Latest