docs icon indicating copy to clipboard operation
docs copied to clipboard

Inline Operation - Document if it requires 'fetch' operation also

Open realtebo opened this issue 11 months ago • 5 comments

Page: https://backpackforlaravel.com/docs/6.x/crud-operation-inline-create

I am setting up field as

    CRUD::field([
            'name' => 'address',
            'inline_create' => true,
        ])
        ->type('relationship')
        ->label('Address')
        ->wrapper(['class' => 'form-group col-md-6'])
    ;

Note: i am omitting ajax

Anyway, this field is automatically a select 2 with ajax.

This need fetch operation, I think. Because opening the select2, an ajax call to a non-existent route ../fetch/... is fired

Please, document it, (or explain me what am I doing wrong).

realtebo avatar Aug 04 '23 14:08 realtebo

Yes, you need to use the fetch operation. It's documented here under the relationship field.

Hope this would get you through. Please remember to close the issue.

For more queries, this would be a better place https://github.com/Laravel-Backpack/community-forum/issues Good day @realtebo

karandatwani92 avatar Aug 05 '23 06:08 karandatwani92

Thanks, but add a side note into the documentation of inline becase if,as us, are not using the relationship field, you will not face this row of documentation..

I suggest to explain it also here: https://backpackforlaravel.com/docs/6.x/crud-operation-inline-create because it's more related to inline that to relationship

Also, this is not a question about how to do things. We already found the answer, it's a (big) suggestion to improve doc. This is why we decided to open a doc issue and not a Q/A on forum.

Also, as you can see, we are NOT using "ajax" => "true" so it's a bit confusing that it's mandatory to use it and the fetch operation. Just

realtebo avatar Aug 06 '23 10:08 realtebo

Anyway, this field is automatically a select 2 with ajax.

Hmm I don't think that's intentional. I think that's a bug, to be honest. If you ask me, you should be able to use inline_create with a non-ajax field. I don't see why not.

@pxpm let me do a TLDR for you (everybody correct me if I'm wrong here):

  • @realtebo tried to add a relationship field
  • as soon as he use inline_create relationship turned the field into an AJAX one
  • but that triggered an error, because he didn't have the Fetch operation set up

Are you aware of this restriction @pxpm ? Did we choose to do this? Should we document or fix this?

tabacitu avatar Aug 09 '23 09:08 tabacitu

Like you rephrased looks like a restriction, but it's actually the "defaults" we choose at the time and I am still standing by them as I still think they are the most convenient.

The field is indeed by default an ajax field and that's mentioned in the docs: image

We even mention a Fetch caveat there: image

It's NOT MANDATORY to use FetchOperation, you can use data_source => 'your.endpoint.

pxpm avatar Aug 09 '23 14:08 pxpm

What I get after reading the conversations is, Info is already there but not in the highlights.

@tabacitu do you feel to do something here? It feels like you as the right person to take over this.

karandatwani92 avatar Aug 14 '23 09:08 karandatwani92