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

lucas.sanner54070
lucas.sanner54070

Let's say I have set the following field in my fields.yaml file:

     my_field:
         label: My field
         type: partial
         path: ~/plugins/vendorname/pluginname/models/post/_mypartial.htm 

Now is it possible to retrieve the model from my partial ? Something like $this->getModel() ?

Last updated

mjauvin
mjauvin

The model can be referenced in the partial as follow:

<?php $model ?>
or
<?php $formModel ?>

The field as:

<?php $field ?>
or
<?php $formField ?>

and the field value as:

<?php $value ?>
or
<?php $fieldValue ?>

ref. https://github.com/octobercms/october/blob/develop/modules/backend/widgets/form/partials/_field_partial.htm

Last updated

mjauvin
mjauvin

Also, you can shorten your path definition with the "$" symbol which refers to the plugins folder by itself.

path: $/vendorname/pluginname/models/post/_mypartial.htm
mjauvin
mjauvin

Use this code in your partial to see what's available:

<?php dump($this->vars); ?>
lucas.sanner54070
lucas.sanner54070

Great tips ! Thanks.

noideawhattotypehere
noideawhattotypehere

Its actually just $model (in form partials) and $record (in list partials)

1-6 of 6

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