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

    ifox

    06/30/2021, 5:00 PM
    yes. It looks like you're using HandleMedias on the repository but not HasMedias on the model.
  • s

    Sami

    06/30/2021, 5:03 PM
    wow, that worked. Would you recommend me any concrete section from doc to understand these relations?
  • i

    ifox

    06/30/2021, 5:05 PM
    I think a section like that is definitely missing. Right now the best we have is the content of the CRUD modules section. Those traits are all setup for you when you generate a module, but I guess we're missing to explain how to add each feature individually. We're working on it.
  • u

    user

    07/02/2021, 9:44 AM
    I was wondering if there was a way to check why
    Your submission could not be validated please fix and retry
    pops up? How do I find the source of the error?
  • i

    ifox

    07/02/2021, 10:26 AM
    browser console and/or Laravel logs
  • u

    user

    07/02/2021, 12:09 PM
    How do I rename the title field to something else? I've realized that I can rewrite the default layout by defining my own
    create.blade.php
    but I'm still missing a title on the 'show_all_templates' view. How do I rewrite that view to show my custom
    title
    field?
  • i

    ifox

    07/02/2021, 12:11 PM
    assuming you mean the index/list view, using
    $titleColumnKey
    and
    $indexColumns
    in the controller
  • u

    user

    07/02/2021, 12:31 PM
    That worked well, how do I rename the ordering 'Title' and set the orderBy to be the same as my column?
  • i

    ifox

    07/02/2021, 12:35 PM
    what did you set $indexColumns to? you have control over that label and to enable sort there
  • u

    user

    07/02/2021, 12:35 PM
    Copy code
    $this->indexColumns += [
                'name' => [
                    'title' => 'Name',
                    'fieldName' => 'Name',
                    'field' => 'name',
                ],
            ];
  • i

    ifox

    07/02/2021, 12:37 PM
    add sort => true, and you should override it as a class property entirely, not add to it in a function
  • i

    ifox

    07/02/2021, 12:38 PM
    https://twill.io/docs/#controllers
  • u

    user

    07/02/2021, 1:03 PM
    RIght, that did the job, but it forced me to have the ordering column visible at all times.
  • u

    user

    07/02/2021, 1:05 PM
    Copy code
    protected $titleColumnKey = 'name';
       // protected $defaultOrders = ['name' => 'asc'];
        protected $defaultIndexOptions = [
            'create' => true,
            'edit' => true,
            'publish' => true,
            'bulkPublish' => true,
            'feature' => false,
            'bulkFeature' => false,
            'restore' => true,
            'bulkRestore' => true,
            'forceDelete' => true,
            'bulkForceDelete' => true,
            'delete' => true,
            'duplicate' => true,
            'bulkDelete' => true,
            'reorder' => false,
            'permalink' => true,
            'bulkEdit' => true,
            'editInModal' => true,
        ];
    
        public function __construct(Application $app, Request $request)
        {
            parent::__construct($app, $request);
    
            $this->indexColumns['title'] = [
                    'title' => 'Name',
                    'field' => 'name',
                    'sort' => false,
                ];
        }
  • u

    user

    07/02/2021, 1:06 PM
    Nvm, I just need to omit the index columns, they are responsible for the extra ordering.
  • u

    user

    07/02/2021, 1:07 PM
    On the other hand, I was wondering how does image validation work? I'm using
    media
    type field, yet when I set-up the validator inside the Request for either create or edit, I keep getting the 'image field is required message', even though the image has been uploaded.
  • u

    user

    07/02/2021, 1:08 PM
    Copy code
    public function rulesForCreate()
        {
            return [
                "name" => "string|max:180|required",
                //"image" => "required"
            ];
        }
  • u

    user

    07/02/2021, 1:08 PM
    Even though the image was attached to the field, it is never sent to the backend
  • u

    user

    07/02/2021, 1:11 PM
    I do get a lot of errors when trying to crop the image as well, I'm using the default
    $mediasParams
    settings.
  • u

    user

    07/02/2021, 1:11 PM
    Cannot ready property
    width
    /
    medium
    /
    destroy
    of undefined.
  • i

    ifox

    07/02/2021, 1:17 PM
    ha yeah that's not how you'd validate medias field, they are coming through a
    medias
    array keyed by the image role name
  • i

    ifox

    07/02/2021, 1:19 PM
    when exactly are you seeing this error, and is that the full error?
  • u

    user

    07/02/2021, 1:21 PM
    So, whenever I click on a crop button this appears:
  • p

    pboivin

    07/02/2021, 1:24 PM
    Hey @User , sure looks like a role name issue. Can you double-check that your
    medias
    field corresponds to what you have defined in
    $mediasParams
    ?
  • u

    user

    07/02/2021, 1:24 PM
    Yup did that, both in the model, and in the
    form.blade.php
    +
    create.blade.php
    the name is the same 'cover' (the default one)
  • i

    ifox

    07/02/2021, 1:25 PM
    image fields are not compatible within the
    create
    modal
  • i

    ifox

    07/02/2021, 1:26 PM
    the error sounds like the image you're trying to crop is missing metadata/not able to be rendered as a url
  • u

    user

    07/02/2021, 1:26 PM
    Hmm.. it doesn't work in
    form.blade.php
    either. I just downloaded skype logo as well just to give it a test regarding the metadata, but it still gives the same error.
  • u

    user

    07/02/2021, 1:27 PM
    Buuuuuuut, I did move the
    form.blade.php
    to be a modal as well
  • u

    user

    07/02/2021, 1:27 PM
    Yep, when I removed the modal, the crop works.
1...404142...484Latest