Will generate the form file app/Admin/Forms/Setting.php
<?phpnamespaceApp\Admin\Forms;useEzadev\Admin\Widgets\Form;useIlluminate\Http\Request;classSettingextendsForm{/** * The form title. * * @varstring */public $title ='Settings';/** * Handle the form request. * * @paramRequest $request * * @return\Illuminate\Http\RedirectResponse */publicfunctionhandle(Request $request) {//dump($request->all());admin_success('Processed successfully.');returnback(); }/** * Build a form here. */publicfunctionform() {$this->text('name')->rules('required');$this->email('email')->rules('email');$this->datetime('created_at'); }/** * The data of the form. * * @returnarray $data */publicfunctiondata() {return ['name'=>'John Doe','email'=>'[email protected]','created_at'=>now(), ]; }}
In the form class above, $title is used to set the title of the form, and the form item is built in the form method. The method is consistent with model-form, and the data method is used to set the form item. Default data
Then put the above form into your page as follows:
After filling in the data submission form on the page, the request will go to the handle method, where you can add your data processing logic. After the processing is complete, return a response object to the front end:
publicfunctionhandle(Request $request) {// Get data from the $request object to process...// Add a success promptadmin_success('Success');// or an error messageadmin_success('Asu Ada Error....'); // Go back to the original form page after processing is complete, or jump to another page by returning `redirect()` method
returnback(); }
Tab form
tab form Organize multiple forms by using the line selection card, click the tab to jump to the corresponding form page