"Feedback" and "Ask a question" do not work.

Phoca Cart - complex e-commerce extension
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47887
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: "Feedback" and "Ask a question" do not work.

Post by Jan »

So the situation in fact means, that for now it is possible to render tel form field in Phoca Cart including pattern, but Joomla does not render it.

Will be great if you can test this PR:
https://github.com/joomla/joomla-cms/pull/38852


In fact it means, open:
layouts/joomla/form/field/tel.php

And add following code (line cca 62)

FROM:

Code: Select all

$required ? 'required' : '',
    $dataAttribute,
TO:

Code: Select all

$required ? 'required' : '',
    !empty($pattern) ? 'pattern="' . $pattern . '"' : '',
    $dataAttribute,
Then if you fill the phone field in Phoca Cart:

Image

- pattern and validate: tel, then the form field becomes tel and the validation works

Image

Jan
If you find Phoca extensions useful, please support the project
kosh2323
Phoca Member
Phoca Member
Posts: 20
Joined: 13 Sep 2022, 08:03

Re: "Feedback" and "Ask a question" do not work.

Post by kosh2323 »

Hi Jan. On your advice, I tried the "phone" field for the input specified in the pattern, but only in the user profile form, yes it works. But in the form of "Ask a question" - a menu item, or "Ask a question about a product", these fields of these forms are still not checked.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47887
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: "Feedback" and "Ask a question" do not work.

Post by Jan »

Hi, if I change this XML:
components/com_phocacart/models/forms/question.xml

FROM:

Code: Select all

<field name="phone" type="text" class="form-control" size="40" label="COM_PHOCACART_FIELD_F_PHONE_LABEL" description="COM_PHOCACART_FIELD_F_PHONE_DESC" filter="string" />
TO:

Code: Select all

<field name="phone" type="tel" class="form-control" size="40" label="COM_PHOCACART_FIELD_F_PHONE_LABEL" description="COM_PHOCACART_FIELD_F_PHONE_DESC" filter="string" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" />
Then it works OK for me :idea:

Image

Jan
If you find Phoca extensions useful, please support the project
kosh2323
Phoca Member
Phoca Member
Posts: 20
Joined: 13 Sep 2022, 08:03

Re: "Feedback" and "Ask a question" do not work.

Post by kosh2323 »

Checked 3 times it doesn't work.

I'm sorry, I figured it out, tested it after upgrading to 4.2.3, and after updating Joomla overwritten its files, including tel.php , and I see the old

Code: Select all

$required ? 'required' : '',
    $dataAttribute,
in it and if I change it

Code: Select all

$required ? 'required' : '',
    !empty($pattern) ? 'pattern="' . $pattern . '"' : '',
    $dataAttribute,

to the new version, then everything works, thank you. Only now it turns out that with each update it will need to be changed again.
kosh2323
Phoca Member
Phoca Member
Posts: 20
Joined: 13 Sep 2022, 08:03

Re: "Feedback" and "Ask a question" do not work.

Post by kosh2323 »

It would be nice to also enter explanations under the fields themselves for users, explaining the correctness of the input, for example, "enter the phone number in the format 123-123-1234". And it is even better to adjust and configure these fields in the admin panel in the "Questions" section. Since there is a field setting during registration, delivery, in the user profile, but there is no field setting when asking questions. And this is also important. There are separate settings in the "settings", you can attach an article to the explanation, but there is no field to explain the correctness of the input under the field, there is also no placeholder.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47887
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: "Feedback" and "Ask a question" do not work.

Post by Jan »

Hi, usualy when adding the phone number, nobody cares about the format because it can be different, some people add it with or without prefix, etc. etc. This is why mostly there is text field and any value is accepted (without prefix, with prefix, without spaces, with spaces, three numbers next to each other or two numbers next to each other, etc. - the goal is not to burden user with adding right format but to get the telephone contact from him in any form)

The phone form field:

<field name="phone" type="text" class="form-control" size="40" label="COM_PHOCACART_FIELD_F_PHONE_LABEL" description="COM_PHOCACART_FIELD_F_PHONE_DESC" filter="string" />

includes description so such description can be used, when override of the form is made.

So there, e.g. per language override you can write each instruction so user is able to see what format to add into the form.

Jan
If you find Phoca extensions useful, please support the project
kosh2323
Phoca Member
Phoca Member
Posts: 20
Joined: 13 Sep 2022, 08:03

Re: "Feedback" and "Ask a question" do not work.

Post by kosh2323 »

Again, this field

Code: Select all

COM_PHOCACART_FIELD_F_PHONE_DESC
is shown only if the user registers, but in the feedback form, or "Ask a question about the product" it is not shown at all, right?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47887
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: "Feedback" and "Ask a question" do not work.

Post by Jan »

Hi, as default, it is not displayed in frontend.
If you find Phoca extensions useful, please support the project
Post Reply