Twill 3 fieldsets
# ❓questions
l
Quick question, when anybody has time...: Created an (extra) side field set on the model form, which has a (default, I'd imagine) 'Options' title. How to I change that to eg 'Opengraph'. Tried a few things, and struggled to find any reference to it. Must be easy to do? PS, don't want to create another fieldset inside that one, which is documented. Thanks in advance
e
I hope I understand this right^^ You just want to change the title of the fieldset to opengraph?
Copy code
$form->addFieldset(
    Fieldset::make()->title('Opengraph!')->id('opengraph')->fields([
      // Fields come here.
    ])
);
l
@EpicKau Thanks for taking the trouble to reply. Using the form builder for this just caused a render error related to an unknown function `Fieldset::render
(doesn't exist in
A17\Twill\Services\Forms\Fieldset`). Sppent some time investigating this, but couldn't get anywhere. As a workaround, I pedalled back to using blade forms, but adding a named fieldset to the
@section('sideFieldSet)
inserts it inside the 'Options' fieldset. Again, appreciate the reply.
e
@Lucius Vorenus the fieldset class doesnt have a render function. Could you try this:
Copy code
public function getSideFieldsets(TwillModelContract $model): Form
    {
        $form = parent::getSideFieldsets($model);

        //  https://github.com/area17/twill/issues/2214
        //  test dummy
        $form->add(Input::make()->name('dummy')->label('dummy'));

        $form->addFieldset(
            Fieldset::make()->title('Opengraph')->id('opengraph')->fields([
                Input::make()->name('og_title')->label('OG Title'),
                Input::make()->name('og_description')->label('OG Description'),
                Files::make()->name('og_image')->label('OG Image')
            ])
        );

        return $form;
    }
l
@EpicKau Ok, you are epic, Kau! Just to be clear, what file do you want me to put that function in? (Spot the newbie!) I promise to try this later, and report back. I think I know what I did wrong. For whatever reason (can't find the docs I was reading) I was supplying the name key of precreated form fields into the array of fields. The full field definition, as you supplied, is far far more intuitive, and the new docs are pointing to that. However, may I suggest a small change at https://github.com/area17/twill/blob/3.x/docs/content/1_documentation/3_modules/8_form-builder.md#fieldsets ? Instead of
//Fields come here
(3 instances), could you change it to
//Field definitions come here
, or similar, for the hard of understanding amongst us? Even having an actual field definition, like you took the trouble to do above, would be even better. Thanks again. The support (and patience) on here is fantastic. More people should be telling you that! ( Twill has really caught my imagination (this from somebody who used to use Drupal))
e
@Lucius Vorenus thanks mate, but I'm just a noob too. The feedback and acknowledgements should go to @ifox and his team 🙂
l
@ifox May I suggest a small change at https://github.com/area17/twill/blob/3.x/docs/content/1_documentation/3_modules/8_form-builder.md#fieldsets for clarity? Instead of
//Fields come here
(3 instances), could you change it to
//Field definitions come here
, or similar, for the hard of understanding amongst us? You probably need a day or two's sleep after the last few! The new docs look very good!
i
For sure @Lucius Vorenus feel free to open a PR with that change. Did a bit of reorg so that link is down, sorry!
l
@ifox Actually never created a pr before (don't judge me too harshly! 🫢 ), so this might be a good time to learn to do one! You OK if I do that for typos and other small points?
i
that'd be great, let me know if you have any questions. for small points you can let GitHub guide you, everything can be done in the UI