This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

mcustiel
mcustiel

Hi. I started working in a feature that requires a very dynamic backend configuration and I am using a model with (id, description, parameters) where parameters is a jsonable field. I created my own formwidget to add content to the parameters field and it is working ok. Now I would like to integrate a file upload in my formwidget and, since there is already a file upload formwidget, I would like to render it and access the uploaded file info from my widget to save it in my parameters field. I tried this in my formwidget class:

public function __construct($controller, $formField, $configuration = [])
{
        parent::__construct($controller, $formField, $configuration);
        $this->fileUpload = $this->makeFormWidget(FileUpload::class, $formField, $configuration);
}

And in my formwidget's partial:

<?= $this->fileUpload->render() ?>

But it fails with this error (October\Rain\Exception\ApplicationException): Model 'Your\Plugin\Models\YourModel' does not contain a definition for parameters'.

Does anyone has any idea about how to compose multiple form widgets to create a new one?

Thank you very much.

Last updated

mcustiel
mcustiel

Well, it seems it is a specific problem of the FileUploader form widget. I tried to do it using colorPicker just to use a simpler widget and it worked. This is what I did:

public function __construct($controller, $formField, $configuration = [])
{
        parent::__construct($controller, $formField, $configuration);
        $newField = clone $formField;
        $newField->arrayName = $this->formField->getName();
        $newField->fieldName = 'colorPicker';
        $this->colorPicker = $this->makeFormWidget(ColorPicker::class, $newField, $configuration);
}

Last updated

MarSch
MarSch

Is this also possible with normal formfields? For Example A Formwidget combined with a Dropbox-Field? I tried it with function makeFormField... but get always an error, the function would not be existing. Can anyone help me?

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.