$form element with #type => ‘submit’ with custom submit and validate function

$form[‘copy_local’] = [
‘#type’ => ‘submit’,
‘#prefix’ => ‘<br>’,
‘#name’ => ‘public’,
‘#value’ => $this->t(‘Copy local public files to S3’),
‘#validate’ => [
[$this, ‘copyLocalValidateForm’],
],
‘#submit’ => [
[$this, ‘copyLocalSubmitForm’],
],
];

public function copyLocalValidateForm(){

//Code Here

}

When we click on this submit button then the #validate is called first and the #submit.It will check for the custom method in same class and then call that method.

 

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s