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

Unable to call component method. Public method [submit] not found on component #330

Open
fajarsakti opened this issue Jan 31, 2024 · 4 comments
Labels
in progress Something is being worked on or being addressed.

Comments

@fajarsakti
Copy link

fajarsakti commented Jan 31, 2024

There's an error in the submit method, but it worked fine before. I've tried to use the submit method in my livewire class but it's not updating.

class MyCustomComponent extends MyProfileComponent
{
    protected string $view = "livewire.my-custom-component";

    public static $sort = 10;

    public array $data;

    public function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make('phone')
                    ->tel()
                    ->telRegex('/^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\.\/0-9]*$/')
                    ->label('Phone Number'),
                TextInput::make('address')
                    ->label('Address')
            ])
            ->statePath('data');
    }
}

here's my AdminPanelProvider.php

class AdminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->default()
            ->id('admin')
            ->homeUrl('/')
            ->path('dashboard')
            ->login()
            ->registration()
            ->passwordReset()
            ->profile()
            ->colors([
                'primary' => Color::Teal,
            ])
            ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
            ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
            ->pages([
                Pages\Dashboard::class,
            ])
            ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
            ->widgets([
                Widgets\AccountWidget::class,
                // Widgets\FilamentInfoWidget::class,
            ])
            ->middleware([
                EncryptCookies::class,
                AddQueuedCookiesToResponse::class,
                StartSession::class,
                AuthenticateSession::class,
                ShareErrorsFromSession::class,
                VerifyCsrfToken::class,
                SubstituteBindings::class,
                DisableBladeIconComponents::class,
                DispatchServingFilamentEvent::class,
            ])
            ->authMiddleware([
                Authenticate::class,
            ])
            ->plugin(
                BreezyCore::make()
                    ->myProfileComponents([MyCustomComponent::class])
                    ->myProfile(
                        shouldRegisterUserMenu: true, // Sets the 'account' link in the panel User Menu (default = true)
                        shouldRegisterNavigation: false, // Adds a main navigation item for the My Profile page (default = false)
                        hasAvatars: true, // Enables the avatar upload form component (default = false)
                        slug: 'my-profile' // Sets the slug for the profile page (default = 'my-profile')
                    )
                    ->avatarUploadComponent(fn ($fileUpload) => $fileUpload->disableLabel())
                    ->passwordUpdateRules(
                        rules: [Password::default()->mixedCase()->uncompromised(3)], // you may pass an array of validation rules as well. (default = ['min:8'])
                        requiresCurrentPassword: true, // when false, the user can update their password without entering their current password. (default = true)
                    )
            )
            ->brandLogo(asset('build/assets/logo.png'))
            ->databaseNotifications();
    }
}
@jeffgreco13
Copy link
Owner

This worked before?
Pretty sure you still need to set up your submit() method on the component:

public function submit()
{
  $data = $this->form->getState);
  // use your data
}

@jeffgreco13 jeffgreco13 added the in progress Something is being worked on or being addressed. label Jan 31, 2024
@peppezer
Copy link

peppezer commented Mar 7, 2024

Is it possible to restore the user form model without having to specify it in the component mount?

@cgsmith
Copy link
Contributor

cgsmith commented Jun 6, 2024

I have an issue with this as well using 2.2.1.1 also in 2.4.1. Either the code should be fixed or documentation added about adding submit() on the component in the documentation.

@dharen008
Copy link

same issue i reported here, i think extended files are not working

#362 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress Something is being worked on or being addressed.
Projects
None yet
Development

No branches or pull requests

5 participants