sadikoff / crud-maker-bundle Goto Github PK
View Code? Open in Web Editor NEWGenerate symfony flex crud is simple!
Home Page: https://koff.pro/
License: MIT License
Generate symfony flex crud is simple!
Home Page: https://koff.pro/
License: MIT License
since won't work without security-csrf and form
should these be added to compoer require --dev for this package?
.. matt ..
the NEW controller method should be BEFORE the SHOW controller method in the controller template
since
//new
is parsed by the SHOW method as
/{id = 'new'}
which then fails with an Object Not found ParamConverter annottion exception
SOLUTION:
locate the new() method BEFORE the show() method in: Controller.tpl.php
I'm new to PUll reuqests for open source stuff - but I'll try to set one one via a fork :-)
.. matt ..
_delete_form.tpl.twig currently:
<form method="post" action="{{ path('<?= $route_name; ?>_delete', {'<?= $entity_identifier; ?>':identifier}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ identifier) }}">
<input type="submit" value="Delete">
</form>
should be:
<form method="post" action="{{ path('<?= $route_name; ?>_delete', {'<?= $entity_identifier; ?>':identifier}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ identifier) }}">
<input type="submit" value="Delete">
</form>
i.e. method should be DELETE (with no underscore prefix)
when you generate code for an entity all works well apart from the new route. It seems to be matching that route to the show action. Am thinking this might be solved by moving the new action above the show action.
According to https://symfony.com/doc/2.6/book/routing.html#book-routing-conditions earlier routes win. Tried it and it worked on 1 controller, don't know if there are bigger considerations. Once again good work.
/MakeCrud.php on line 29
!!
!! Fatal error: Class Koff\Bundle\CrudMakerBundle\Maker\MakeCrud contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Symfony\Bundle\MakerBundle\MakerInterface::generate) in .../testing02_unit/vendor/koff/crud-maker-bundle/src/Maker/MakeCrud.php on line 29
!!
missing method generate()
??
clicking a DELETE button in the Edit form doesn't result in
isSubmitted() being true after a handleRequest()
so the actions to remove/flush the entity aren't executed, and no delete from DB takes place
to get this to work I had to add in a condition to submit the form, adopting example from Symfony docs
but should this be necessary?
if required, then we need to update the Generated code for the Controller ...
public function delete(LoggerInterface $logger, Request $request, Category $category)
{
$logger->info('1 :: got here');
$form = $this->createDeleteForm($category);
$form->handleRequest($request);
$logger->info('2 :: isSubmitted = ' . $form->isSubmitted());
if ($request->isMethod('DELETE')) {
$form->submit($request->request->get($form->getName()));
if ($form->isSubmitted() && $form->isValid()) {
$logger->info('3 :: in the DELETE bit');
$em = $this->getDoctrine()->getManager();
$em->remove($category);
$em->flush();
}
}
I'd like to know if there's any way to overwrite the twig templates without having to modify the bundle you've made.
thanks and great work
If csrf and session are disabled delete action can't handle request and proceed with deletion
these lines missing from MakeCrud->getFiles()
__DIR__.'/../Resources/skeleton/templates/_form.tpl.php' => 'templates/'.$params['route_name'].'/_form.html.twig',
__DIR__.'/../Resources/skeleton/templates/_delete_form.tpl.php' => 'templates/'.$params['route_name'].'/_delete_form.html.twig',
so Twig include error when running
.. matt ..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.