Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Pathfield doesn't recognise the path assigned by js

Avatar

Level 3

Dear community,

 

I'd like to build my own custom carousel that allows the user to not only choose the file in pathfield from rootPath,

but also upload the file from local to the given asset folder and automatically fill the pathfield with the asset path just created.

 

Yes now I can upload files onto asset and yes I can get the path and assign it to pathfield input.

But, pathfield cannot recognise the value assigned by js.. (I use required property to testify it)  

 

pleasefill.png

 

Interestingly, I backspaced the last g and typed that g back again, the path worked.

 

pass.png

 

Would like to know how to fix this, any comments or suggestions are welcome 🙂

1 Accepted Solution

Avatar

Correct answer by
Level 3

Issue solved update:

 

In brief, the problem was about I cannot assign value to pathfield input by using js.

Yes, the value had been put into the input (by getting its AEM original class ".coral-InputGroup-input"),

but AEM doesn't recognise it (see below).

pathfield input.png

The pathfield issue.png

 

If you see the pathfield properties, there is a name property (./filePath),

and that property is actually the key to solved this.

properties.png

Get back to the page, F12 and find the name in the elements.

modified element.png

 

Use js to find this element and assign value to it then it works, input is not the right target.

View solution in original post

5 Replies

Avatar

Community Advisor

HI @YuSheng 

 

How are you setting the value into the dialog? Is it after the upload happens and then JS gets the path and pastes it?

If yes, you also need to write JS logic to validate if the field is empty and remove the error message and submit the dailog.

 

Hope this helps!

 

Thanks,
Kiran Vedantam.

Avatar

Level 3

Dear Kiran,

 

Here is my js, I use a servlet to upload the file to given asset folder:

 

螢幕擷取畫面 2022-04-28 160709.png

So basically even there's a path selected in the pathfield input, new file's path will just replace it.

Am still trying modifying my js to make it work...

 

Thanks for the feedback!

 

=============== Update after 2 hrs ===============

 

With some brain-storming with my friends we fixed this! It's not about validation, will update the solution later :)))

Avatar

Community Advisor

As you have mentioned pathfield cannot recognise the value assigned by js.

Are you getting something like /content/dam/yourproject/clubbanner-01.jpg by js?

Just a random thought any extra space is getting appended while the assigning the value by js.

Avatar

Level 3

Hi DEBAL_DAS

Haha I did examine it several times to make sure no extra space.

 

Thanks for the comment!

Avatar

Correct answer by
Level 3

Issue solved update:

 

In brief, the problem was about I cannot assign value to pathfield input by using js.

Yes, the value had been put into the input (by getting its AEM original class ".coral-InputGroup-input"),

but AEM doesn't recognise it (see below).

pathfield input.png

The pathfield issue.png

 

If you see the pathfield properties, there is a name property (./filePath),

and that property is actually the key to solved this.

properties.png

Get back to the page, F12 and find the name in the elements.

modified element.png

 

Use js to find this element and assign value to it then it works, input is not the right target.