Jump to content

[RESOLVED] helpers - form.tpl - input type = file


be_tnt
 Share

Recommended Posts

Hello!

 

I have added an helper form on my module configuration page. This form has a field with type = "file":

array(
  'type'   =>   'file',
  'label'  =>   $this->l('Select a file:'),
  'desc'  =>  $this->l('Banner picture. Extension allowed: jpeg, png, jpg, gif.'),
  'name'   =>   'banner_image',
  'required' =>   true,
  'lang'  =>  false,
  'display_image' => true,
 ),

 

The display_image allows to display the image for an existing element (information about this image is located in fields_value array). My problem is that the helper form.tpl add a delete link below the picture and in my case, it does not work:

 

	{elseif $input.type == 'file'}
	 {if isset($input.display_image) && $input.display_image}
	  {if isset($fields_value.image) && $fields_value.image}
	   <div id="image">
		{$fields_value.image}
		<p align="center">{l s='File size'} {$fields_value.size}kb</p>
		<a href="{$current}&{$identifier}={$form_id}&token={$token}&deleteImage=1">
		 <img src="../img/admin/delete.gif" alt="{l s='Delete'}" /> {l s='Delete'}
		</a>
	   </div><br />
	  {/if}
	 {/if}
	 <input type="file" name="{$input.name}" {if isset($input.id)}id="{$input.id}"{/if} />
	 {if !empty($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer"> </span></span>{/if}

 

I do not see what should be {$identifier}={$form_id}, how to set those variables and what is the different call made when you click on the delete.

 

Any idea?

Edited by be_tnt (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

I resolved my issue by creating my own file input type for my module.

 

FYI: to override the form.tpl in your module, you have to create your form.tpl in the following folder: \modules\{your module name}\views\templates\admin\_configure\helpers\form

  • Like 1

Share this post


Link to post
Share on other sites

  • 1 year later...

I resolved my issue by creating my own file input type for my module.

 

FYI: to override the form.tpl in your module, you have to create your form.tpl in the following folder: \modules\{your module name}\views\templates\admin\_configure\helpers\form

 

Hi just hit this old post and wonder if you can help me.

 

I am trying to override form tpl in my module just as you but my override is not working if I place in the above directory. I am using PS 1.5.6. However, I have discovered that if I manually copy my overriden form.tpl to admin\themes\default\template\controllers\my_custom\helpers\form\ folder then my override is loaded. Also, for the above path to work my back office module controller must be named as AdminMyCustomController.php. In the controller, I am using the default renderForm method.

 

I would appreciate if you can point me to exactly what I need to do in order to properly override form.tpl from my module's custom admin controller. Thanks

Edited by sttaq (see edit history)

Share this post


Link to post
Share on other sites

  • 6 months later...

I am trying to override form tpl in my module just as you but my override is not working if I place in the above directory.

 

Make sure you have set this line in Helper loader:

$helper = new HelperForm();
$helper->module = $this;
..
return $helper->generateForm($form);

Without module line - overrides aren't loaded at all. Spent hours debugging myself.... <_<

(Should be right away, but i normally do uninstall and reinstall for the module too)

Edited by megamurmulis (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

  • 2 months later...

I resolved my issue by creating my own file input type for my module.

 

FYI: to override the form.tpl in your module, you have to create your form.tpl in the following folder: \modules\{your module name}\views\templates\admin\_configure\helpers\form

I did the same, the only difference is that in my case I need to override a file from helpers/list folder.

 

But after reinstalling the module and clearing the cache nothing changed. Do I have to override that file in code manually also?

Share this post


Link to post
Share on other sites

  • 2 months later...

Hi,

 

I have two file input fields. 

 

array("type"=>"file","label"=>$this->l('Logo:'),"name"=>"logo","display_image"=>true,"col"=>6,"desc"=>$this->l('Upload seller logo from your computer')),
array("type"=>"file","label"=>$this->l('Shop Image:'),"name"=>"shop_image","display_image"=>true,"col"=>6,"desc"=>$this->l('Upload shop image from your computer'))
 
 
But in my form , the two file input fields are generating with same name as below.
 
<input type="file" name="logo">
<input type="file" name="logo">
 
Please help me :(

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More