Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add connected fields support to the Twill 3 form builder #2323

Merged
merged 5 commits into from
Nov 29, 2023

Conversation

joyceverheije
Copy link
Collaborator

@joyceverheije joyceverheije commented Aug 28, 2023

Description

This has been reported many times on Discord as missing from the new form builder. Developers were forced to use a BladePartial field to use the @formConnectedField directive or component in a Blade file.

Now they can simply use ->connectedTo($fieldName, $fieldValues) on a form builder field to use this functionality. Additional options are supported by a third parameter of type array.

Examples

Checkbox::make()->name('use_source_description'),
Wysiwyg::make()
    ->name('source_description')
    ->connectedTo('use_source_description', true),
Wysiwyg::make()
    ->name('description')
    ->connectedTo('use_source_description', false),
Checkbox::make()->name('use_source_description'),
Wysiwyg::make()
    ->name('source_description')
    ->connectedTo('use_source_description', true, ['keepAlive' => true]),
Wysiwyg::make()
    ->name('description')
    ->connectedTo('use_source_description', false, ['keepAlive' => true]),

When set to false (default value) keepAlive was not destroying standard input fields
@Jigsaw5279
Copy link

I've literally JUST been trying to find how to do this when the notification about this PR came in..

@ifox ifox merged commit 5bddccf into area17:3.x Nov 29, 2023
7 of 9 checks passed
@Tofandel
Copy link
Contributor

There is one thing that's not possible with the connectedTo approach that is possible with blade and that is nested connectedTo for multiple dependencies

@ifox
Copy link
Member

ifox commented May 23, 2024

@Tofandel good point, could you share a Blade example?

@Tofandel
Copy link
Contributor

Tofandel commented May 23, 2024

Eg an input that shows if 2 fields have a specific value

<x-twill::formConnectedFields
    field-name="type"
    field-values="video"
>
  <x-twill::formConnectedFields
      field-name="provider"
      field-values="youtube"
  >
      <x-twill::input
          name="video_embed"
          label="Video embed"
      />
  </x-twill::formConnectedFields>
</x-twill::formConnectedFields>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants