Timeline for Page keeps blank when creating a custom form. Controller and routes are set up correctly
Current License: CC BY-SA 4.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 2, 2021 at 8:51 | comment | added | hardy123480 | So, at the end I figured it out and posted a complete answer. Overall, your answer wasn't very helpful and didn't really contribute to the actual problem since I already posted in my initial question that Block, Controller and routes were working correctly. However, your steps to debug are kind of helpful. I leave it that way, so thanks anyway. | |
Apr 2, 2021 at 6:23 | comment | added | Jimmy |
To get example, you can just search in Magento's code base, try to find some class that extend the Template block (because you are extending it, you want to see how other people, who also extend it, write code). To read about the error, you should enable error reporting in Magento (please google for that), and check your var/log folder to get detail about the error
|
|
Apr 2, 2021 at 5:17 | comment | added | hardy123480 | Ok, now I left out the complete construct method, and the form shows up. What's wrong with the construct and why do I need it anyway? This is so strange. | |
Apr 2, 2021 at 5:12 | comment | added | hardy123480 | Hm, I don't get it. There's not much in the Block which could cause the template to go blank, isn't it? Could you please give an example? | |
Apr 2, 2021 at 5:02 | comment | added | Jimmy |
Now as you said, the normal content is ok, but when you starting adding data from your block, then it stops working => It must have something with the code you add in the block, so you can check again by start with small code such as $block->setTest('value') and then in your template, you do $block->getTest() . It's all about follow the flow/code
|
|
Apr 2, 2021 at 5:00 | comment | added | Jimmy | You can just follow my (extra) steps above | |
Apr 2, 2021 at 4:40 | comment | added | hardy123480 | Ok, now I put content of form into template. It shows. Next I put content into Block. Form disappears. So the error has to be into above code of the Block. Any idea? | |
Apr 2, 2021 at 4:33 | comment | added | hardy123480 | Ok, but then it passes all 4 steps. So where's the error? It should work, shouldn't it? I really don't understand. | |
Apr 2, 2021 at 4:27 | comment | added | Jimmy |
The reason you see Interceptor is because Magento uses it to make it work with plugin mechanism, you don't need to worry when you see that interceptor word
|
|
Apr 2, 2021 at 4:26 | comment | added | Jimmy | It's your block, you can use it now to get data into your template | |
Apr 2, 2021 at 4:22 | comment | added | hardy123480 |
Thanks for the debugging steps. It passes the first 3 checks! However, check 4 is giving me Mageplaza\HelloWorld\Block\Index\Interceptor . That's not my block, isn't it? Name of my block is helloworld_index_index as defined in /view/frontend/layout/helloworld_index_index.xml or am I wrong? Any help would be appreciated.
|
|
Apr 2, 2021 at 2:35 | history | answered | Jimmy | CC BY-SA 4.0 |