Using FormBuilder
Created 5 years ago by pooria


(First: I could not find any docs about available form options like wrapper_view, success_message, ... . Do they exist? )

I'm using this code in my controller to render a form in front-end:

public function profile(FacultyFormBuilder $form, $id) {
        $form->setOption('wrapper_view', 'theme::profile');
        $form->setOption('success_message', trans('theme::form.success_message'));

The resume field in backend is set to anomaly.field_type.file But I want to change it to anomaly.field_type.upload in front-end. I tried this code but it didn't work because $form->getFields() is empty:

        $form->setFields(array_merge($form->getFields(), [
            'resume'    => [
                'type'  => 'anomaly.field_type.upload'

However, If I use a custom FormBuilder and set this In its class:

protected $model = FacultyModel::class; 
protected $fields = [
    'resume'    => [
            'type'  => 'anomaly.field_type.upload',
            'config'    => [
                'folder' => 'documents'

, The form works fine. But the problem here is that I have to pick every field I need instead of skipping fields that I don't need!

finnito  —  5 years ago

@pooria I can’t test this while on my phone, but in your custom form builder you should be able to add ”*” to $fields to include all fields by default and then just add the fields you don’t want to your skips.

Hope that helps!