Closed bluedarter2 closed 3 years ago
Hi @bluedarter2. Thank you for your report. To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release
For more details, please, review the Magento Contributor Assistant documentation.
Please, add a comment to assign the issue: @magento I am working on this
Join Magento Community Engineering Slack and ask your questions in #github channel.
:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.
:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
I did a separate new install of Magento 2.4.0, and out of the box the Contact Us form works correctly. This must be an upgrade bug. This makes me really worry about choosing Magento for my new online store.
@bluedarter2 not sure how do you update but i upgrade direct from 2.3.5-p1 to 2.4.0 by composer way
Can't reproduce issue Also double check composer.json have this require "magento/composer-root-update-plugin": "~1.0"
"require": { "magento/product-community-edition": "2.4.0", "magento/composer-root-update-plugin": "~1.0" }
Lastly when you update 2.4.0 magento require elastic search service must setup
You also need update your magento instance config
bin/magento config:set catalog/search/engine elasticsearch7 bin/magento config:set catalog/search/enable_eav_indexer 1 bin/magento config:set catalog/search/elasticsearch7_server_hostname elasticsearch bin/magento config:set catalog/search/elasticsearch7_server_port 9200 bin/magento config:set catalog/search/elasticsearch7_index_prefix magento2 bin/magento config:set catalog/search/elasticsearch7_enable_auth 0 bin/magento config:set catalog/search/elasticsearch7_server_timeout 15
update elasticsearch7_server_hostname with your value
@mrtuvn I used composer to do the upgrade, per the magento 2.4 upgrade instructions. I had already installed elasticsearch 7.8.1 previously when I ran the patch upgrade to 2.3.5-p1 (again using composer to do the patch).
However, I noticed that elasticsearch had stopped working at some point so I can't be absolutely positive it was running successfully at the time I did the magento 2.4 upgrade.
Yes I do have the requires specified:
"require": {
"magento/composer-root-update-plugin": "~1.0",
"magento/product-community-edition": "2.4.0",
"php-webdriver/webdriver": "^1.8",
"psr/container": "^1.0",
"symfony/doctrine-bridge": "^5.1",
"symfony/serializer": "^5.1"
I have elasticsearch running correctly now.
Also I entered the admin back-end and checked all the Elasticsearch settings. The only thing different from yours is the Elasticsearch server hostname is "localhost", since I am running it locally on the same server as Magento. I tested the elasticsearch connection and it reports "Successful! Test again?".
I don't know what I should do next to fix this install?
Thanks, Evelyn
@bluedarter2: this most likely happened because of this change in 2.4.0: https://github.com/magento/magento2/pull/25523/files
In the form.phtml
file, they now call $viewModel->getUserName()
, and $viewModel
is something which is added through the contact_index_index.xml
file.
I'm not sure if the same thing can be accomplished with {{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}
, if you can somehow add that view_model
argument as well in there, I don't think so, but I'm not sure.
So that's where you should start looking for a solution I think.
@hostep Thanks. I disabled that page, and now the Contact Us link goes to the 404 page not found. To be honest, I started stepping through the Magento store setup just after the first of the year (Jan 2020) then had to stop working on it. I've just picked it up again, and I can not for the life of me remember how to affect what happens when that link in the footer is clicked. I find Magento to be pretty difficult to understand/configure for a newbie. The shop I need to replace is a pre-Joomla (Mambo) php_shop (pre-VirtueMart).
[edit to add] OK, I "fixed" it by removing the "Contact Us" page that I had created.
@hostep if you put {{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}} in cms page (ex: home) the entire page will break just like @bluedarter2 describe It's cause viewModel not available In real use case maybe some 3rd-party theme will want reuse contact form template somewhere and call without define viewModel probably cause error
@hostep @mrtuvn In fact I was following the Magento 2 documentation when I started working with Magento 2, and the 2.4 docs still use this example! So the documentation should have been updated to reflect whatever is the correct thing to do: https://docs.magento.com/user-guide/stores/contact-us.html#method-2-without-sample-data
Item #3 there.
So perhaps someone can tell me how to correct the page?
@bluedarter2 Technically if you need add some content in contact page you should extend contact template in theme. Add some additional code to call cms block inside this new template. Go to admin create new cms block and add content you want in backend. In that way you can avoid break code. No need to use cms page for contact like document
@bluedarter2: thanks for the link to the documentation! I've opened an issue with them to correct the documentation: https://github.com/magento/merchdocs/issues/648, not sure how long that's going to take
There are probably multiple ways to accomplish what you want to accomplish, but I'm afraid you'll have to search around a bit, the current documentation does not seem to be accurate anymore.
Hi. Docs team here. What would be the proper fix for this? We can easily update the docs but would like to know the recommended way to do this. Please leave a comment in #648 and we will make the update. Thanks.
@dobooth is talking about https://github.com/magento/merchdocs/issues/648 btw
Unfortunately I currently don't have time to look into this in detail I'm afraid.
@hostep who did the code change? Surely they would know the correct way a user, such as myself, would need to react to their code change - and can give guidance to the docs people.
Hi @bluedarter2, maybe @rafaelstz knows the answer, but I think it won't be possible anymore to insert the contactform block into a cms page if it has required arguments, but I'm not 100% sure...
if magento can introduce new way to inject viewModel in wysiwyg block/page possible resolve this problem In the meantime i think we can update doc to avoid confusing and make problem for user Previously -> create page (We don't need this way) New way -> create cms block and use default function widget to put block to specific area . By this way we don't even need touch in code ( no code break, editable or modifiable from backend )
I checked and we don't have the XML customizations available in the CMS pages anymore, so we can't fix it via admin panel. The page that contains the contact form must implement the view_model via XML.
<referenceContainer name="content">
<block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml">
<container name="form.additional.info" label="Form Additional Info"/>
<arguments>
<argument name="view_model" xsi:type="object">Magento\Contact\ViewModel\UserDataProvider</argument>
</arguments>
</block>
</referenceContainer>
@rafaelstz Thanks for the clarification. This is an upgrade breakage that should have been noted as such in the 2.4.0 release notes, "Incompatible Changes" https://devdocs.magento.com/guides/v2.4/release-notes/backward-incompatible-changes/index.html. Then the User Guide documentation for Contact Us should be updated to provide a new, correct, example of how to customize the Contact Us content if one doesn't have the sample data.
@bluedarter2 the guide updated https://docs.magento.com/user-guide/stores/contact-us.html#method-2-without-sample-data
I checked and we don't have the XML customizations available in the CMS pages anymore, so we can't fix it via admin panel. The page that contains the contact form must implement the view_model via XML.
<referenceContainer name="content"> <block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"> <container name="form.additional.info" label="Form Additional Info"/> <arguments> <argument name="view_model" xsi:type="object">Magento\Contact\ViewModel\UserDataProvider</argument> </arguments> </block> </referenceContainer>
Can you please explain more step by step if possible like what file to copy/paste the current contact page html from the cms manager to, and what file to put this xml code in?
have same issue
using this block:
{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}
please help
thanks
You cannot call in CMS block. Try do it via widget or layout @heneral
You cannot call in CMS block. Try do it via widget or layout @heneral
please kindly teach me how to do it @mrtuvn because i am first time with magento 2..
very appreciate if you help me
thanks so much
It's depend on your requirements and how complex on customise on contact you want The easy way is modify/update content in contact page Create new file contact_index_index.xml in your theme for customises Details you can read from this doc https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/layout-extend.html or https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/xml-manage.html Take it's easy take your time for learn it. Magento is hard. You should learn basic things first
It's depend on your requirements and how complex on customise on contact you want The easy way is modify/update content in contact page Create new file contact_index_index.xml in your theme for customises Details you can read from this doc https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/layout-extend.html or https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/xml-manage.html Take it's easy take your time for learn it. Magento is hard. You should learn basic things first
already created it but the problem i am using the root/vendor not the app/design, the result was error.. thanks for that @mrtuvn, yeah magento is so hard.. please kindly help me.. i think this is a bug on magento 2.4.0
@mrtuvn i try to create again, but still showing this
😫 The docs are still extremely vague... Like, could it be any more vague?! 😭
Still not clear from the docs what will and won't break it?
Devving Magento 2 is such a nightmare. And I'm not a noob either. The core code is a mess. Full of 🧐🤨😬😑. The frontend framework is "totally jacked". I could go on for minutes. But anyway...
Can't there be a really simple example like "to edit contact page content override the file in your theme like 'vendor/theme/Magento_Contact/contact_index_index.xml', and then call in your old 'contact-us-content' CMS block like this"? Or a simple example on how to import the contact form into a custom .phtml template? 😶
I checked and we don't have the XML customizations available in the CMS pages anymore, so we can't fix it via admin panel. The page that contains the contact form must implement the view_model via XML.
<referenceContainer name="content"> <block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"> <container name="form.additional.info" label="Form Additional Info"/> <arguments> <argument name="view_model" xsi:type="object">Magento\Contact\ViewModel\UserDataProvider</argument> </arguments> </block> </referenceContainer>
You can follow this
If you call form via CMS page your template will missing view_model argument. That's reason your page will break. Some old theme still missing view_model and not update following Magento Implement. Another option is overwrite entire block contact by your own file (not recommended). You have to manually update your file with magento
same error how can resolve help me
Note your theme could be from app folder or vendor folder
First create file follow app/design/frontend/YourVendorBrand/yourThemeName/Magento_Contact/templates/form.phtml
Copy content from this file (or use your own file) https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Contact/view/frontend/templates/form.phtml If you want customise content file feel free customise in your file in theme . You can place cms block from this templates and modify it from backend (no need to edit code template for update)
Second (Optional but most important since 2.4.0 magento introduced viewModel but almost 3rd-party theme provider not follow standard could miss this thing) => Lead to issue
Add layout
app/design/frontend/YourVendorBrand/yourThemeName/Magento_Contact/layout/contact_index_index.xml
content this file you can follow
https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Contact/view/frontend/layout/contact_index_index.xml
You must have define argument viewModel
infile layout xml if in your templates form.phtml created in previous step call to viewModel. If template you call viewModel ($block->getViewModel()) but somehow in layout you don't define viewModel => Error happen
Before 2.4.0 ✅ in your cms page from backend you can call direct contact form following {{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}
After 2.4.x ❌
You can't do that anymore! Any guide from stackoverflow or magento.stackexchange is outdated. If error happen recheck steps above if you used custom theme or custom modules that affected to contact area! Conclusion No call contact form block from cms page. Instead do custom contact form template in theme
@hareshpatel @BB-000 @heneral @bluedarter2 @salesigniter
If it helps, this is how we created a bespoke Contact Us page for 2.4.2 that looks exactly like our previous page, which utilised the now-defunct direct block insertion method. The layout we previously used featured a full-width Google Map over two responsive columns - the left column contained the store's contact details, and the right column contained the Magento contact form.
First we created three new CMS blocks containing: (1) the Google Map, (2) the store's contact details and opening times with a title bar at the top of the column, and (3) the title bar for the contact form such that it matches the column alongside it.
The instructions for creating a base layer override can be found here > https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/layout-override.html but in short, one needs to create a new file in the theme directory thus:
How you layout and style your page is up to you, but this is how ours now looks (I don't profess to be an expert with the Magento layout files so feel free to correct any superfluous or non-best-practice syntax).
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<title>Contact Us</title>
</head>
<body>
<!-- add Google map (block ID: google_map) inside a new div -->
<referenceContainer name="content">
<container name="contact.map" as="contactMap" label="Contact Map" htmlTag="div" before="-" htmlClass="contact-map">
<block class="Magento\Cms\Block\Block" name="google-map">
<arguments>
<argument name="block_id" xsi:type="string">google_map</argument>
</arguments>
</block>
</container>
</referenceContainer>
<!-- add two responsive columns inside existing main column under map -->
<referenceContainer name="content">
<container name="contact.details.row" as="contactDetailsRow" htmlTag="div" after="-" htmlClass="row">
<container name="contact.details.info" as="contactDetailsInfo" htmlTag="div" after="-" htmlClass="col-md-6 contact-info"/>
<container name="contact.details.form" as="contactDetailsForm" htmlTag="div" after="-" htmlClass="col-md-6 contact-form"/>
</container>
</referenceContainer>
<!-- add store details (with title) in left-hand column -->
<referenceContainer name="contact.details.info">
<container name="contact.info" as="contactInfo" label="Contact Info" htmlTag="div" after="-" htmlClass="contact-us-info">
<block class="Magento\Cms\Block\Block" name="contact-us-info">
<arguments>
<argument name="block_id" xsi:type="string">contact_us_info</argument>
</arguments>
</block>
</container>
</referenceContainer>
<!-- add form container and title in right-hand column -->
<referenceContainer name="contact.details.form">
<container name="contact.form" as="contactForm" label="Contact Form" htmlTag="div" after="-" htmlClass="contact-us-form">
<block class="Magento\Cms\Block\Block" name="contact-form-title">
<arguments>
<argument name="block_id" xsi:type="string">contact_form_title</argument>
</arguments>
</block>
</container>
</referenceContainer>
<!-- add Magento contact form as per original contact_index_index.xml file -->
<referenceContainer name="contact.form">
<block class="Magento\Contact\Block\ContactForm" name="contactForm" after="-" template="Magento_Contact::form.phtml">
<container name="form.additional.info" label="Form Additional Info"/>
<arguments>
<argument name="view_model" xsi:type="object">Magento\Contact\ViewModel\UserDataProvider</argument>
</arguments>
</block>
</referenceContainer>
</body>
</page>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!
Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.4-develop
branchDetails
- Add the comment @magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 5. Add label Issue: Confirmed
once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hi @bluedarter2 ,
We have tried to reproduce this issue as per the mentioned steps, but we are unable to do the same. We have followed below URL to upgrade the Magento from 2.3.5-p1 to 2.4.0:
https://devdocs.magento.com/guides/v2.3/comp-mgr/cli/cli-upgrade.html
Before Upgrade - 2.3.5-p1 Admin dashboard with version information:
Contact us page before upgrade:
After Upgrade - 2.4.0 Admin dashboard with version information:
Contact us page after upgrade:
Please check once at your end and let us know if you still facing any issue related with that.
Hello @bluedarter2,
We are unable to hear from you since past 14 days. So we are closing this issue for now. If you still facing this issue either you can reopen this ticket or create new ticket.
Thanks
@magento give me 2.4-develop instance
Hi @ioweb-gr. Thank you for your request. I'm working on Magento instance for you.
Hi @ioweb-gr, here is your Magento Instance: https://ff3f25818cb462cb912ab36996cc0082.instances.magento-community.engineering Admin access: https://ff3f25818cb462cb912ab36996cc0082.instances.magento-community.engineering/admin_adc5 Login: 22d07861 Password: 5fcba63efc8e
Hi @engcom-Hotel , why was this issue closed as cannot reproduce? it's perfectly fine reproducible in latest develop instance
Step1. Create a CMS page and add a contact form block to it
{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}
Step2. Open the page in frontend and see the error
The issue is that the addition of a viewModel inside the contact form block, leads to making the contact form block being unusable in other cms pages or blocks.
Moreover this cannot be fixed using a layout update for the specific page
e.g.
adding an xml layout instruction like this on the file app/design/frontend/Vendor/theme/Magento_Cms/layout/cms_page_view_id_[your-identifier].xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceBlock name="contactForm">
<arguments>
<argument name="view_model" xsi:type="object">Magento\Contact\ViewModel\UserDataProvider</argument>
</arguments>
</referenceBlock>
</page>
Doesn't make a difference. I think this issue should be reopened as it's a valid bug. There's also no documentation on how to add the
@ioweb-gr: please read the entire thread, it was decided that this is no longer possible in Magento 2.4.0 and higher. The documentation has been updated to reflect that. And please ignore the engcom team's responses, they usually don't know what they are talking about, they only care about closing as many issues as they possibly can and somehow get away with it.
Try following some tutorials of how custom frontend code works in Magento and you'll eventually get there, I'm sure that doing this will help you further in other features that you might want to add in the future.
I've implemented a workaround by extending the contact form block and using the extended one but my point is that this is a bug anyhow and should be addressed.
Currently it's the contact form but soon it may be others as well. We should have a way to reuse blocks in cms pages
Preconditions (*)
Debian 10, Apache 2.4, PHP 7.3.19, mysql Ver 15.1 Distrib 10.3.22-MariaDB Initially using Magento 2.3, with Magento Blank theme and no sample data or customized code. Had the start of a store, with basic data. The "Contact Us" footer link was basic, but worked fine.
After upgrade from Magento 2.3.5-p1 to Magento 2.4.0, the form does not render and generates an error.
Steps to reproduce (*)
Expected result (*)
Actual result (*)
The error is as follows: