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
ifox
ifox3y ago
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.
@foreach($items as $item)
{{ $item->title_header }}
@endforeach
@foreach($items as $item)
{{ $item->title_header }}
@endforeach
If title_header is a field on your forms module, I'm not sure from your screenshots
trompix
trompixOP3y ago
@ifox And how can it affect the result that I have data in the block?
ifox
ifox3y ago
I don't understand your question. Please clarify what you are trying to display in the block.
trompix
trompixOP3y ago
@ifox
ifox
ifox3y ago
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
trompix
trompixOP3y ago
@ifox Did I understand you correctly? The last screenshot shows the form I want to get the data from.
ifox
ifox3y ago
i don't understand your screenshot, where is the browser field? and what is title_header? A field on the block?
trompix
trompixOP3y ago
My field is in a block.
ifox
ifox3y ago
$block->input('title_header') would render a title_header field on a block
trompix
trompixOP3y ago
@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
ifox
ifox3y ago
call renderBlocks() on the article
trompix
trompixOP3y ago
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' => [ ...... ]
ifox
ifox3y ago
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
Want results from more Discord servers?
Add your server