JohnathonKoster / meerkat-statamic-marketplace

A beautiful and streamlined comment system for @Statamic.
https://stillat.com/meerkat
GNU General Public License v3.0
2 stars 0 forks source link

Meerkat v1 Form tag is not generating in Statamic v2 #3

Open mrkaluzny opened 3 years ago

mrkaluzny commented 3 years ago

Form tag is not being generated

{{ form:set is="meerkat" }} {{ meerkat:create }} {{ fields }}
<label>{{ display }}</label>
<input type="text" name="{{ field }}" value="{{ old }}" />
{{ /fields }} {{ /meerkat:create }} {{ /form:set }}

Results in

 =""="" data-meerkat-form="comment-form"&gt;
<input type="hidden" name="_token" value="3R2w5qidWn8EGrOjBFxFCOVzG9AeckXj60Y8NsSN">
<input type="hidden" name="meerkat_context" value="74d6e866-57e6-4003-9874-48b87c2cf2d9">
<input type="hidden" name="_params" value="eyJpdiI6ImlkU3k5Y3gxVlZFVXJFcEhNb1NNYUE9PSIsInZhbHVlIjoiWndndlwvUzdodzRTajdHVldoVGc5a2pueGFzRVVBUGFFVUdwOGNKdURpNXBUaW1QckZJaUZFSXpEbkdVU3l3U3kiLCJtYWMiOiI2ZDlkMDBhODcxN2FmMGYwOGE2YWNiNmU0OTBjNTM2YjE1NDRkZWQ2M2U5NDlhZTU0ZDIyMjE3NDMzMGU1YmMxIn0=">
<label>comment</label>
<input type="text" name="comment" value="">
<label>name *</label>
<input type="text" name="name" value="">
<label>email *</label>
<input type="text" name="email" value="">
<label>website</label>
<input type="text" name="website" value="">
<label>post</label>
<input type="text" name="post" value="">
<label>notifications</label>
<input type="text" name="notifications" value="">
<div class="comments__new__form"> =""="" data-meerkat-form="comment-form"&gt;<input type="hidden" name="_token" value="3R2w5qidWn8EGrOjBFxFCOVzG9AeckXj60Y8NsSN"><input type="hidden" name="meerkat_context" value="74d6e866-57e6-4003-9874-48b87c2cf2d9"><input type="hidden" name="_params" value="eyJpdiI6ImlkU3k5Y3gxVlZFVXJFcEhNb1NNYUE9PSIsInZhbHVlIjoiWndndlwvUzdodzRTajdHVldoVGc5a2pueGFzRVVBUGFFVUdwOGNKdURpNXBUaW1QckZJaUZFSXpEbkdVU3l3U3kiLCJtYWMiOiI2ZDlkMDBhODcxN2FmMGYwOGE2YWNiNmU0OTBjNTM2YjE1NDRkZWQ2M2U5NDlhZTU0ZDIyMjE3NDMzMGU1YmMxIn0="> <label>comment</label> <input type="text" name="comment" value=""> <label>name *</label> <input type="text" name="name" value=""> <label>email *</label> <input type="text" name="email" value=""> <label>website</label> <input type="text" name="website" value=""> <label>post</label> <input type="text" name="post" value=""> <label>notifications</label> <input type="text" name="notifications" value=""></div>

Any ideas how to fix this?

JohnathonKoster commented 3 years ago

Interesting - what does it output if you remove the {[ form:set }} and {{ /form:set }] tags?

Re-reviewing the documentation - I don't think both should be present there.

mrkaluzny commented 3 years ago

The output is the same. Also did you changed the format of comments? I'm trying to update an older project to latest v2 Statamic and Meerkat can't read comments that where saved

JohnathonKoster commented 3 years ago

The comment format should not have changed - I will need to pull a fresh copy of the latest v2 Statamic and debug the form tag (realistic time lines put results for that sometime later this week).

mrkaluzny commented 3 years ago

There’s also an issue with fetching comments line 291 in ApiRoutes.PHP (trying to get property of null) I’ll add in the full error tomorrow. But with a broken form I can’t really see what’s the data structure is for comments.

@JohnathonKoster full log for comments fetching.

ErrorException: Trying to access array offset on value of type null 
in /home/vagrant/Code/terzakis-new/site/addons/Meerkat/Routes/APIRoutes.php:291
Stack trace:
#0 /home/vagrant/Code/terzakis-new/site/addons/Meerkat/Routes/APIRoutes.php(291): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 [internal function]: Statamic\Addons\Meerkat\MeerkatController->Statamic\Addons\Meerkat\Routes\{closure}()
#2 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Support/Collection.php(469): array_map()
#3 /home/vagrant/Code/terzakis-new/site/addons/Meerkat/Routes/APIRoutes.php(293): Illuminate\Support\Collection->map()
#4 [internal function]: Statamic\Addons\Meerkat\MeerkatController->getApiComments()
#5 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Container/Container.php(507): call_user_func_array()
#6 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Container/Container.php(604): Illuminate\Container\Container->call()
#7 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Container/Container.php(502): Illuminate\Container\Container->callClass()
#8 /home/vagrant/Code/terzakis-new/statamic/core/Http/Controllers/StatamicController.php(124): Illuminate\Container\Container->call()
#9 /home/vagrant/Code/terzakis-new/statamic/core/Http/Controllers/StatamicController.php(93): Statamic\Http\Controllers\StatamicController->callControllerMethod()
#10 [internal function]: Statamic\Http\Controllers\StatamicController->controllerTrigger()
#11 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(256): call_user_func_array()
#12 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(164): Illuminate\Routing\Controller->callAction()
#13 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(112): Illuminate\Routing\ControllerDispatcher->call()
#14 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}()
#15 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func()
#16 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#17 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func()
#18 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(114): Illuminate\Pipeline\Pipeline->then()
#19 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(68): Illuminate\Routing\ControllerDispatcher->callWithinStack()
#20 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Routing/Route.php(203): Illuminate\Routing\ControllerDispatcher->dispatch()
#21 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Routing/Route.php(134): Illuminate\Routing\Route->runWithCustomDispatcher()
#22 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(708): Illuminate\Routing\Route->run()
#23 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}()
#24 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func()
#25 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#26 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func()
#27 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(710): Illuminate\Pipeline\Pipeline->then()
#28 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(674): Illuminate\Routing\Router->runRouteWithinStack()
#29 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\Routing\Router->dispatchToRoute()
#30 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(236): Illuminate\Routing\Router->dispatch()
#31 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()
#32 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func()
#33 /home/vagrant/Code/terzakis-new/site/addons/SeoPro/Middleware/GenerateReport.php(13): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#34 [internal function]: Statamic\Addons\SeoPro\Middleware\GenerateReport->handle()
#35 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#36 /home/vagrant/Code/terzakis-new/statamic/core/Http/Middleware/TransformsRequest.php(31): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#37 [internal function]: Statamic\Http\Middleware\TransformsRequest->handle()
#38 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#39 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#40 [internal function]: Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle()
#41 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#42 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#43 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle()
#44 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#45 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#46 [internal function]: Illuminate\Session\Middleware\StartSession->handle()
#47 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#48 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#49 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle()
#50 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#51 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#52 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle()
#53 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#54 /home/vagrant/Code/terzakis-new/statamic/core/StaticCaching/Middleware/Retrieve.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#55 [internal function]: Statamic\StaticCaching\Middleware\Retrieve->handle()
#56 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#57 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#58 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle()
#59 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#60 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#61 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func()
#62 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(122): Illuminate\Pipeline\Pipeline->then()
#63 /home/vagrant/Code/terzakis-new/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(87): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#64 /home/vagrant/Code/terzakis-new/index.php(167): Illuminate\Foundation\Http\Kernel->handle()
#65 {main}
mrkaluzny commented 3 years ago

@JohnathonKoster Have you had a chance to look into that issue?

mrkaluzny commented 3 years ago

@JohnathonKoster With APIRoutes.php there's an issue with in_response_to_url

Changing

$data['comment_count'] = collect($items)->where('in_response_to_url', $data['in_response_to_url'])->count();

to

if ($data) {
    $data['comment_count'] = collect($items)->where('in_response_to_url', $data['in_response_to_url'])->count();
} else {
    $data['comment_count'] = collect($items)->count();
}

That makes it work as expected

The tags issue is connected directly to formOpen() function. I've managed to find the issue it's in Meerkat/MeerkatTags.php line 96

Original

$this->parameters['attr'] = $this->parameters['attr'] . '|data-meerkat-form:comment-form';

Updated

$this->parameters['attr'] = $this->parameters['attr'] . 'data-meerkat-form:comment-form';

It seems like that | caused to create an empty attr -> ="" breaking the form. Right now the form is working as expected.