$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

Linux Commands

1. cd- It stands for change directory.
Usage: if you are at some directory on terminal and want to move to another
directory then use cd pathname/path.

2. sudo -super user do. Means if the permission of a file is given to owner the others can access by using sudo.
3. locate- it is used to search for a file.
4. tail- it is used to print last 10 lines of each files to standard output.

5. cp – copy paste

6. grep -r “filename” – ¬†Search for the selected word in whole document.