Fórum

Creating form field to upload images

thumbnail
Viviana Salcedo, modificado 6 Anos atrás.

Creating form field to upload images

New Member Postagens: 10 Data de Entrada: 25/09/17 Postagens Recentes
Hello,

I am trying to create my own costume form field, because I am using Liferay 7 forms to create diferente forms that need to upload images and documents. I am new on the development of Liferay and would like a little bit of help.
For the moment I am based on these tutorial , but I don't understand how can I add the logic to save my file. I have been looking for other examples to upload images directly to document Library but I can not figure out how to add the logic for these type of projects (form-fields) and not mvc-protect.

For now I have the initial template example generated by eclipse IDE and I little change over the .soy file:
{template .FormFieldUpload autoescape="deprecated-contextual"}
	<div class="form-group FormFieldUpload-form-field" data-fieldname="{$name}">
		{if $showLabel}
			<label class="control-label">
				{$label}

				{if $required}
					<span class="icon-asterisk text-warning"></span>
				{/if}
			</label>

			{if $tip}
				<p class="liferay-ddm-form-field-tip">{$tip}</p>
			{/if}
		{/if}
		<input class="field form-control" id="{$name}" name="{$name}" {if $readOnly}readonly{ if} type="file" value="{$value}">
	</div>
{/template}


Can anyone help me with the logic to save data over document library?
thumbnail
Jagan Mohan Jayaraman, modificado 6 Anos atrás.

RE: Creating form field to upload images (Resposta)

New Member Postagens: 10 Data de Entrada: 19/02/17 Postagens Recentes
Hi Viviana,

I find your question somewhat hard to comprehend, but it looks like you are looking for a custom file upload element for Forms that you can configure to allow image types only, and further to be able to save the uploaded images into the Document Library.

The news from the 2017 Symposium is that Liferay 7.1, which is coming out in Q2 of 2018, will have a big upgrade to Forms, including a built-in File Upload element that will do exactly what I listed above.

If you can't wait until then, your only option is to create your own File Upload element, as we have done for one of our projects.

TTFN,
Jagan.
Michael El Khoury, modificado 4 Anos atrás.

RE: Creating form field to upload images

New Member Postagens: 9 Data de Entrada: 18/09/19 Postagens Recentes
Hello Jagan,

The upload element in the 7.1 version has 2 problems which are essential for the project i'm working on.
1-it doesnt permit uploading multiple files.

2-it points to a private folder when clicked, so when not signed it, and we try to upload a file, the login page is shown in the upload popup, i guess it's because it's by default pointing to a private folder. I didn't find a way to configure the default folder for the upload element.

So this being said, do you have any idea that can help me and Viviana Salcedo?

Thank you
thumbnail
Christoph Rabel, modificado 4 Anos atrás.

RE: Creating form field to upload images

Liferay Legend Postagens: 1554 Data de Entrada: 24/09/09 Postagens Recentes
I agree, that Upload field behavior is superweird.
I have never tried it, but you can implement your own form fields:
https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/creating-form-field-types