Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#restful_upload { id = upload, text="Go!" } - does not have field text #131

Open
ad-pro opened this issue Dec 4, 2020 · 5 comments
Open

Comments

@ad-pro
Copy link

ad-pro commented Dec 4, 2020

Looks like element #restful_upload does not have field text

@choptastic
Copy link
Member

Wow, you're right. Thanks for bringing it up. I'm an idiot. I've removed the text attribute from the docs to represent this.

I will plan on implementing the text attribute later using something like this: http://jsfiddle.net/1pc9pcev/ But for now, to ensure the documentation is correct, I've removed the attribute, and removed the html_encode attribute, as that attribute makes no sense without the text field.

So I'll plan on doing this, unless you really need it right now, in which case, are you willing to dive into it?

Related Trello ticket: https://trello.com/c/7igXw8E9

@ad-pro
Copy link
Author

ad-pro commented Dec 4, 2020

No wary. Update docs to be in line with the code :)

There is another mistake: you can not call code as Req:function_name() in the latest releases.
Could you correct it too?

My problem is that #upload{} element does not render correctly.
I try to hack it a little bit but it is too complex :(

Could you make simple analogue of #upload{},

Similar to restful_upload, but that support "normal" events?

Another question is it possible to apply css styles to it. At the moment restful_upload render ugly button.

Regards, Anton

@th31nitiate
Copy link

Its funny I tend to find the same issue when working on nitrogen. The #restful_upload{} does not work. It can retrieve the file name but not the required file.

My understanding is that it is defined like this:

        #restful_form{action="/upload/file", method=post, body=[
            #label{text="Upload your file here"},
            #restful_upload { id = upload, text="Go!" },
            #p{},
            #restful_submit{html_name=submit,text="Submit"}
        ]}

Once this is done then when a file is selected then a submit is clicked. In the case statement it is possible to handle the file by using the request bridge methods with something like this:

    case wf:q(submit) of
        undefined -> form();
        _ -> Req = wf_context:request_bridge(),
              UploadedFiles = Req:post_files().
              ...
    end.

Though this does not seem to be work as the files are not attached nor uploaded. Inspecting the Req returns an empty list.

My problem is that #upload{} element does not render correctly. I try to hack it a little bit but it is too complex :(

I found the only way is to fudge around with the upload element and make a local customized version. I'm still experimenting with this but it seems the most valid method in my view.

I put a column separate from the #restful_form{}. This was the upload are possible as they wont work correctly if the #upload{} is embedded in the rest form.

Another question is it possible to apply css styles to it. At the moment restful_upload render ugly button.

It should work as it inherits the base element which enables you provided your own CSS styling.

Though I was having the same thoughts regarding if I'm using the restful upload correctly ?

@choptastic
Copy link
Member

Interesting. I suspect it may be a file decoding issue in simple_bridge, but I'm not sure at the immediate moment.

@th31nitiate
Copy link

Yh, I think its JS bit, only sticking to the element level stuff, so I cant go that low at the moment unfortunately. Though I will let you know if I see anything interesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants