Jump to content

How to add image field inside module with the HelperForm class


Recommended Posts

hi, am creating a module, and want to use the helperForm and the helperList to manage ans list contents of a slider that i want to integrate within prestashop.

 

so in the ModuleAdminController , after the parent :: __construct(); i have

 

$this->fieldImageSettings = array(
		'name' => 'image',
		'dir' => 'v'
	);
$this->fields_list = array
	( 'image' => array(
			'title' => $this->l('Icon'),
			'align' => 'center',
			'image' =>  $this->fieldImageSettings["dir"],
			'width' => 70,

)),

 

and at the render form :

 

public function renderForm()
{
// Building the Add/Edit form
$this->fields_form = array(
 'legend' => array(
  'title' => $this->l('Edit')
 ),
 'input' => array(
  array(
'type' =>'file',
'label'=>$this->l('Link Icon'),
'name'=>'image',
'required' => false,
'display_image' => true
  ),
  'submit' => array(
'title' => $this->l('   Save   '),
'class' => 'button'
  )
 )
);
return parent::renderForm();
}

 

but when i upload image , i got The image field is required.

Link to comment
Share on other sites

  • 3 years later...

I don't think 'submit' belongs inside 'input', I think it belongs outside ... like:

public function renderForm()
{
  // Building the Add/Edit form
  $this->fields_form = array(
      'legend' => array(
          'title' => $this->l('Edit')
      ),
      'input' => array(
          array(
              'type' =>'file',
              'label'=>$this->l('Link Icon'),
              'name'=>'image',
              'required' => false,
              'display_image' => true
          )
      ),
      'submit' => array(
          'title' => $this->l(' Save '),
          'class' => 'button'
      )
  );
  return parent::renderForm();
}

...but maybe that was just old PS... try that and you'll see :)

Edited by jave.web (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...