Getting fields through a component browser
Good evening, tell me how to properly receive fields through the browser component?
I want to reflect in the preview.
13 Replies
Hi @User142 your $items variable is a collection of Form models, so you can use them like normal Laravel models, not using block helpers. And since it's a collection anyway, it wouldn't work to call the input method on it, you need to iterate on them. Also, you don't need to get the IDs and fetch the records manually, you can directly call
$block->getRelated('forms')
to get the forms collection.
If title_header
is a field on your forms module, I'm not sure from your screenshots@ifox And how can it affect the result that I have data in the block?
I don't understand your question. Please clarify what you are trying to display in the block.
@ifox
I just noticed you have first() on the collection, my bad
remove that foreach then
$items->title would show the title of the first form selected in your browser field, in your case
but I wouldn't call that variable itemS if you're doing first() on that collection, that's what confused me
@ifox Did I understand you correctly?
The last screenshot shows the form I want to get the data from.
i don't understand your screenshot, where is the browser field?
and what is title_header? A field on the block?
My field is in a block.
$block->input('title_header')
would render a title_header field on a block@ifox I have a browser component. In which I connect for example three articles. I have a preview file where I want to display data from these articles (but the data is stored in a block in the article).
browser->article->block->field
call renderBlocks() on the article
Good evening. I solved part of the issue. But I can't fully answer my own question.
How it is possible to receive a field created through??
@formField('block_editor', [
'blocks' => [
......
]
Is
lets discuss your tasks
a block on your form module form?
like I said before calling renderBlocks on your $test variable would render the blocks that you created there
it's great that you're sharing screenshot but you're not explaining what they are, please be more clear about what you're trying to do