Module's edit view does not display data



  • Created a test module based on the testimonials example, but on click of the record to edit the fields are not populated.

    • Already edited entity partials to include field values
    • Using this directive to display values on edit view: {!! Form::normalInput('name', 'Name', $errors, $testimonial) !!}

    Any thoughts?


  • admin

    Hello,

    I moved your question to the Questions category. Also marked your topic as a question, don't forget to mark it as answered when done.

    About your view, you need to send data to your view as any laravel app. Make sure you do, and you will have the data.



  • Hi,

    I would assume that when I followed the process of creating a module using scaffold that the function to return the data will already be set and it only takes a matter of editing the edit-fields.blade.php to show the values on edit.

    // got this in the controller under the edit method
    return view('testimonials::admin.testimonials.edit', compact('testimonial')); <- is this what you mean by returning data to view?

    Thanks.


  • admin

    Correct, that's how you send data to views in laravel.

    What you can do now is dd() the testimonial variable in the controller and start debuging from there.



  • Has anybody solved this? I've encountered the same problem.

    dd() reports that the object is empty. Comparatively, the collection returned on the index view contains correctly populated entities. Interestingly, attempting to edit a record that doesn't exist ('0', for instance) doesn't throw an exception - it seems as though the database isn't being queried at all.

    The module creation tutorial shows that the object is correctly populated when passed to the edit view with no edits required (other than those for translations which are, as noted, seemingly no longer required). I'm going to look investigate the CRUD in a moment, but any interim feedback would be appreciated.


  • admin

    One thing I found out, was that the scaffolding used the plural name in the route binding config, and singular in the route definition itself.

    So the solution for you would be to rename either of those, I usually use singular for this, so I rename the route binding.

    Example:

    $router->bind('products', function ($id) {
        return app(\Modules\Product\Repositories\ProductRepository::class)->find($id);
    });
    

    To

    $router->bind('product', function ($id) {
        return app(\Modules\Product\Repositories\ProductRepository::class)->find($id);
    });
    


  • Ah, that's solved it. Thanks very much.



  • it work for me. Thank you so much.


  • Global Moderator

    Fixed in Workshop tag 1.15.1


Log in to reply
 

Looks like your connection to AsgardCms was lost, please wait while we try to reconnect.