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 placeholder component #411

Merged

Conversation

mallardduck
Copy link
Contributor

@mallardduck mallardduck commented May 7, 2021

This PR allows for using a placeholder element in a form. The intention of this is to provide a UX similar to what LinkedIn does here:

So with this PR, if this UX were needed you could do:

  Components\Grid::make([
      Components\Toggle::make('is_active')
          ->label('Currently working this role')
          ->default(true)
          ->dependable()
          ->stacked(),
      Components\DatePicker::make('started_at'),
// Our conditional field and equivalent placeholder
      Components\DatePicker::make('departed_at')
          ->when(fn ($record) => $record->is_active !== true),
      Components\Placeholder::make('departed_at', 'Present')
          ->when(fn ($record) => $record->is_active === true), // Note the callback logic here is inverted from above.
  ])->columns(3),

The end results would be:
Screen Shot 2021-05-07 at 5 21 01 PM
Screen Shot 2021-05-07 at 5 20 56 PM

@danharrin danharrin merged commit 025afb4 into filamentphp:develop Jun 3, 2021
@danharrin
Copy link
Member

Thanks!

@danharrin danharrin added the enhancement New feature or request label Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants