Hari KT Posted November 21, 2014 Share Posted November 21, 2014 Hi all, I was trying to add an image field to `implements Module, ConfigurableModule ` . When uploading image I was getting error as TemplateFile: Invalid image<pre>#0 [internal function]: InputfieldFile->___processInputAddFile('fdd-1.jpg') #1 public static function getModuleConfigInputfields(array $data) { $inputfields = new InputfieldWrapper(); // $field = wire('modules')->get('InputfieldImage'); // $field->attr('name', 'logo'); // $field->label = __('Logo'); // $field->addOption('logo', 'logo'); // $field->attr('value', isset($data['logo']) ? $data['logo'] : ''); $field = wire('modules')->get('InputfieldFile'); $field->attr('name', 'logo'); $field->label = __('Logo'); $inputfields->add($field); return $inputfields; } I tried with file which gives me invalid extensions. Is there a way to fix it ? Basic idea is to extend a template which can have upload functionality of logo etc. Thank you. Link to comment Share on other sites More sharing options...
Soma Posted November 21, 2014 Share Posted November 21, 2014 $field = wire('modules')->get('InputfieldFile'); That's a Inputfield not a Field! A field is something you add to a template/page and an Inputfield is only the input, so no storage for the image. Link to comment Share on other sites More sharing options...
adrian Posted November 21, 2014 Share Posted November 21, 2014 Not sure it is the only problem, but try FieldtypeImage, rather InputfieldImage. EDIT: What soma said Link to comment Share on other sites More sharing options...
Soma Posted November 21, 2014 Share Posted November 21, 2014 There was many changes to file or images and overall, I had once in ImageManager used a InputfieldFile on a process admin module, set the upload dir etc, and then loaded the file from there to create image pages. But then since 2.5 I think it didn't work suddenly, and I couldn't get Ryan to explain what happens (as so many times) So I'm not sure what's working and what not anymore. Well after hours of trying and thinking I got it working, just something I can't make sense of it. All I remember was that the admin page is used to upload the image from a InputfieldImage, where before it wasn't. This code is interesting, but as said I have no idea what worked and why. https://github.com/somatonic/ImagesManager/blob/master/ImagesManager.module#L173 Ohhh, and you might be on a module settings config screen you are having this? There it won't work anyway as there's no page! 2 Link to comment Share on other sites More sharing options...
adrian Posted November 21, 2014 Share Posted November 21, 2014 You may also find that you need to call getDatabaseSchema($field) to make sure the DB table is updated to include the extra required fields for image and file fields. One additional thing I noticed is that even though this is supposed to take care of adding the tags field, it doesn't seem to work, so I also do the following if I need the tags field added: $sql = "ALTER TABLE `field_imaged` ADD `tags` TEXT NOT NULL"; $query = $this->wire('database')->prepare($sql); $query->execute(); Link to comment Share on other sites More sharing options...
Hari KT Posted November 24, 2014 Author Share Posted November 24, 2014 Yes @Soma, I am from a Module configuration settings page . Link to comment Share on other sites More sharing options...
adrian Posted January 7, 2015 Share Posted January 7, 2015 Just wanted to confirm that the: // make sure the value is of type Pageimages $obj_field->attr("value", new Pageimages($this->page)); fix also works for me. Thanks soma! Link to comment Share on other sites More sharing options...
Hari KT Posted January 7, 2015 Author Share Posted January 7, 2015 > Ohhh, and you might be on a module settings config screen you are having this? There it won't work anyway as there's no page! As Soma mentioned. It is for module configuration I was looking. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now