Jump to content
thirty bees forum
  • 0

What is the proper way to add an image to an Admin Controller ?


SiliticX

Question

I have this module that I made. It works fine, I can create entries and all. But i can't seem to figure out the proper way to use the tools that AdminController is giving me.

I tried adding this in my ObjectModel

'picture' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => false),

And the field in my inputs list:

    if ($id_recipe = (int)Tools::getValue('id_recipe'))
    {
        $item = $this->loadObject();
        $file = '../modules/' . $this->name.'/views/img/'. $item->picture.$this->typeImage;

    } else {
        $file = "";
    }


    $inputs[] = array(
                'type' => 'file',
                'label' => $this->l('Image en-tête'),
                'name' => 'picture',
                'thumb' => ($file!=""&&file_exists($file)) ? $file : '',
                'delete_url' => self::$currentIndex.'&'.$this->identifier.'='.$this->tpl_view_vars['object']->id.'&token='.$this->token.'&deleteImage=1',
            );

Then I tried adding this in my construct:

    $this->fieldImageSettings = array(
        'name' => 'picture',
        'dir' => $this->module
    );
    $this->typeImage = 'jpg';

At this very moment, the field does appear in the edit panel of the object... I've tried looking for tutorials, guides, scoured forums.... I'm lost. Why is it so hard?

PS : Small random question, how do i know which mode i'm in when in renderForm() ?

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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
×
×
  • Create New...