https://twill.io logo
Join DiscordCommunities
Powered by
# ❓questions
  • j

    jefsev

    02/24/2023, 11:46 AM
    Like this:
    Copy code
    public function getForm(TwillModelContract $model): Form
        {
            $form = parent::getForm($model);
    
            $form->add([
                Columns::make()
                    ->left([
                        Input::make()->name('f_name')->label('First name'),
                        Input::make()->name('infix')->label('Infix'),
                        Input::make()->name('l_name')->label('Last name'),
                        Input::make()->name('email')->type('email')->label('Email'),
                    ])
                    ->right([
                        Input::make()->name('phone_nr')->label('Phone number'),
                        Input::make()->name('street_address')->label('Street address'),
                        Input::make()->name('city')->label('City'),
                        Input::make()->name('postal')->label('Postal'),
                    ]),
                Input::make()->name('comment')->type('textarea')->label('Comment'),
            ]);
    
            return $form;
        }
    
        public function getSideFieldsets(TwillModelContract $model): Form
        {
            $form = parent::getForm($model);
    
            $form->add([
                    Input::make()->name('proxeed_men_q')->disabled()->label('Proxeed men quantity')->note('Amount ordered'),
                    Input::make()->name('proxeed_women_q')->disabled()->label('Proxeed women inositol quantity')->note('Amount ordered'),
                    Input::make()->name('order_total')->disabled()->label('Order total'),
                    Input::make()->name('order_nr')->disabled()->label('Order number'),
                    Input::make()->name('mollie_id')->disabled()->label('Mollie id'),
            ]);
    
            return $form;
        }
  • h

    Harings Rob

    02/24/2023, 11:48 AM
    instead of add you can use merge like this:
    Copy code
    public function getForm(TwillModelContract $model): Form
        {
            $form = parent::getForm($model);
    
            return $form->merge([
                Input::make()->name('description')->label('Description')->translatable(),
                Medias::make()->name('cover')->label('Cover image'),
                BlockEditor::make()
            ]);
        }
    $form is a laravel collection so you can use the same methods. merge returns a new instance so you have to return or capture&return it.
  • h

    Harings Rob

    02/24/2023, 11:49 AM
    push also works:
    Copy code
    php
            $form = parent::getForm($model);
    
            $form->push(
                Input::make()->name('description')->label('Description')->translatable(),
                Medias::make()->name('cover')->label('Cover image'),
                BlockEditor::make()
            );
    
            return $form;
  • j

    jefsev

    02/24/2023, 11:50 AM
    Thx 🙂
  • j

    jefsev

    02/24/2023, 11:52 AM
    🙂 loving the form builder in the controller.
  • j

    jefsev

    02/24/2023, 11:52 AM
    Is there also a way to build forms for blocks inside a controller?
  • j

    jefsev

    02/24/2023, 11:54 AM
    Ah i see already. Inside View/Components/Twill/Blocks right?
  • i

    ifox

    02/24/2023, 11:56 AM
    https://github.com/area17/twill/blob/00f2971570c5de0622fe6ae3c8da8565d9ac569d/docs/content/1_documentation/5_block-editor/02_creating-a-block-editor.md#block-component-class
  • j

    jefsev

    02/24/2023, 11:56 AM
    php artisan twill:make:componentBlock 🤩
  • j

    jefsev

    02/24/2023, 11:58 AM
    So than the whole twill folder inside views is not needed anymore.
  • h

    Harings Rob

    02/24/2023, 12:00 PM
    It still is required for repeaters, unless you use inline repeaters.
  • h

    Harings Rob

    02/24/2023, 12:00 PM
    also, form builders are not as flexible as blade forms since you cannot add wrappers/css.
  • i

    ifox

    02/24/2023, 12:01 PM
    And there's the
    BladePartial
    field if you need that
  • j

    jefsev

    02/24/2023, 12:24 PM
    Thanks, appreciate all the help.
  • b

    BlazinglyFast

    02/24/2023, 1:05 PM
    Hey there. I made a form, in which block can be added. I named the block Image. It has only form-field media, which has the name gallery and for form-field media I added extraMetaDatas with the name exitURL. How can I access the exitURL field when rendering that block?
  • i

    ifox

    02/24/2023, 1:15 PM
    Hey @BlazinglyFast you'll need to use $block->imageObject(s) then you can call
    getMetadata
    on that/those objects
  • b

    BlazinglyFast

    02/24/2023, 1:43 PM
    thanks, it worked
  • t

    thelongestsigh

    02/24/2023, 2:31 PM
    what is the best was to show data from repository in blade files?
  • i

    ifox

    02/24/2023, 2:38 PM
    Hi @thelongestsigh do you mean blade files for your frontend?
  • i

    ifox

    02/24/2023, 2:38 PM
    or blade files controlling your twill forms?
  • t

    thelongestsigh

    02/24/2023, 2:55 PM
    i mean blade files in frontend
  • t

    thelongestsigh

    02/24/2023, 2:55 PM
    i tried following the steps in tutorial video 5 but it doesn't work for me
  • i

    ifox

    02/24/2023, 2:57 PM
    videos are a bit outdated at this point, we're working on communicating that clearly with the upcomimg Twill 3 release. Where are you blocked? Twill models are regular models, they come with a forSlug scope if you are using HasSlug on them and from there you can access standard fields like regular model properties and things like medias and blocks through helpers
  • t

    thelongestsigh

    02/24/2023, 3:01 PM
    thanks i'll try to do it that way
  • t

    thelongestsigh

    02/24/2023, 3:31 PM
    How can you get access to an uploaded file from blade frontend?
  • h

    Harings Rob

    02/24/2023, 3:34 PM
    You can access ->file('role')
  • h

    Harings Rob

    02/24/2023, 3:35 PM
    https://twill.io/docs/api/2.x/A17/Twill/Models/Behaviors/HasFiles.html
  • t

    thelongestsigh

    02/24/2023, 3:38 PM
    How can you use it?
  • a

    AntonyPL

    02/24/2023, 4:15 PM
    wihich apprach is better to create a custom modules - create default twill modules or create twill capsules? And why ?
  • i

    ifox

    02/24/2023, 4:48 PM
    If you intend to move the module to a composer package or just want the ability to easily copy a module from your project to another one without having to copy files from the whole Laravel folder structure, use a capsule
1...469470471...484Latest