# |
Dec 14th 2017, 21:15 |
rafael.junqueira.sant |
This is in my controller: if ($this->Services->save($service)) { $this->Flash->success(__('The service has been saved.')); return $this->redirect(['action' => 'index']); } $this->Flash->error(__('The service could not be saved. Please, try again.')); Here is what's in my template: <?= $this->element('flash/success'); ?> <?= |
# |
Dec 14th 2017, 21:00 |
slackebot |
print the error or success message by default? Flash component documentation page didn't help me in this one. Thank you |
# |
Dec 14th 2017, 21:00 |
rafael.junqueira.sant |
Greetings I am trying to use the flash success and error elements, but it is giving me the error "Notice (8): Undefined variable: message [APP/Template\Element\Flash\success.ctp, line 3]" instead of printing the message. I could fix it, but I'm trying to learn cakephp the conventional way, without jerry rigging it. Although I don't see it clearly in the code how the Flash->render becomes the variable $message, shouldn't it just |
# |
Dec 14th 2017, 17:14 |
inoas |
does cakephp remove them somehow? |
# |
Dec 14th 2017, 17:13 |
inoas |
but if I add them to index.php they do not appear |
# |
Dec 14th 2017, 17:13 |
inoas |
but I don't see any... if I add them to webroot/test-cors.php <?php header('Access-Control-Allow-Origin: *') ?> ... I can see them |
# |
Dec 14th 2017, 17:13 |
inoas |
I am setting up cors headers in .htaccess |
# |
Dec 14th 2017, 16:09 |
salewilliam09 |
it true, you can build with your idea. |
# |
Dec 14th 2017, 16:03 |
meder_ |
so i guess component |
# |
Dec 14th 2017, 16:03 |
meder_ |
but i want to make a general method to take options |
# |
Dec 14th 2017, 16:03 |
meder_ |
it's not going to be exactly the same, it'll be customized per each controller |
# |
Dec 14th 2017, 16:02 |
salewilliam09 |
If you want dynamic function, i'm thinking build common or components. |
# |
Dec 14th 2017, 16:01 |
salewilliam09 |
You should build main-Controller and extend from Main for sub-controllers. |
# |
Dec 14th 2017, 15:59 |
meder_ |
i have 1 controller and some code that creates a new entity on a model. i want to do similar functionality in another controller - should i throw this into a model function or a component? |
# |
Dec 14th 2017, 15:56 |
salewilliam09 |
Hi all, I have problem with query and subquery same table Tags, I thinking this is big issue from QueryBuilder? |
# |
Dec 14th 2017, 15:47 |
Hendrix |
Hi |
# |
Dec 14th 2017, 15:44 |
spencdev |
hmic It worked. Thank you |
# |
Dec 14th 2017, 15:31 |
hmic |
anywhere else that gets executed before you fire the event is fine too |
# |
Dec 14th 2017, 15:31 |
spencdev |
I took the documentation waaaaay to literal. Thank you, i'll give it a shot |
# |
Dec 14th 2017, 15:31 |
hmic |
bootstrap.php is a save place |
# |
Dec 14th 2017, 15:30 |
hmic |
yes |
# |
Dec 14th 2017, 15:30 |
spencdev |
hmic I think I see my stupidity now. I put it underneath the NotificationsEvent class. I'm guessing that it's actually suppose to go somewhere else |
# |
Dec 14th 2017, 15:28 |
hmic |
it's not even listing former events or anything, maybe you open an issue on the website for it to get fixed :D |
# |
Dec 14th 2017, 15:27 |
mikesmoniker |
Perhaps off-topic but can anyone tell me what a ticket to CakeFest has been priced at in the past couple of years? The website is just a splash page right now. |
# |
Dec 14th 2017, 15:27 |
hmic |
spencdev: where did you attach the NotificationsEvent? |
# |
Dec 14th 2017, 14:51 |
spencdev |
I'm not quite sure why this event isn't firing. https://gist.github.com/tspencer9303/eb1ffff786e3c21a2a51dc4587b7a0f8 |
# |
Dec 14th 2017, 14:42 |
eax |
Ooh, thanks lorenzo! |
# |
Dec 14th 2017, 14:40 |
lorenzo |
one with `matching` and another with `notMatching` |
# |
Dec 14th 2017, 14:40 |
lorenzo |
eax sounds like the `union()` of 2 queries |
# |
Dec 14th 2017, 14:01 |
spencdev |
Okay, that answers my question. Thanks! |
# |
Dec 14th 2017, 14:00 |
eax |
Hey folks! Cake3 ORM Question: I have the relation Users hasMany UserTags. I need to run a Query that gets Users who either have a certain UserTag, or no UserTags at all. Can anyone tell me how to do that? Thanks! :) |
# |
Dec 14th 2017, 13:59 |
hmic |
spencdev: i'd not want my table to have all the events |
# |
Dec 14th 2017, 13:53 |
spencdev |
So I'm a little confused on the event system. So, I have many tables that need to be able to create notifications and I have a notifications table. I believe the best way to do this is through events? If so, do I have the NotificationsTable implement EventListenerInterface and do it that way? Or create a directory called Events and make that implement EventListenerInterface and use the ORM? |
# |
Dec 14th 2017, 12:45 |
eax |
You're very welcome :) |
# |
Dec 14th 2017, 12:44 |
justcharlz |
oh! okay. thank you very much. Appreciate |
# |
Dec 14th 2017, 12:43 |
eax |
) |
# |
Dec 14th 2017, 12:43 |
eax |
(Also remember that flash should be with a capital F, if you're in Cake 3 |
# |
Dec 14th 2017, 12:43 |
eax |
You redirect away from the page, before setting the flash message ;) Switch the order of the lines, so that you return AFTER $errmsg and $this->Flash->error() :) |
# |
Dec 14th 2017, 12:42 |
justcharlz |
return $this->redirect(['controller' => 'plans','action' => 'subscribe']); $errmsg = $respdata['message']; $this->flash->error(__('Payment error'.$respdata['message'])); |
# |
Dec 14th 2017, 12:42 |
justcharlz |
okay. Thanks. I already did this but don't know why it is not working |
# |
Dec 14th 2017, 12:41 |
eax |
This requires you to have a warning.ctp element under plugins/PluginName/src/Template/Element/Flash for rendering the flash message. And to run $this->Flash->render(); on the page the user is redirected to |