Jump to content

Extra File input field InputfieldPageAutocomplete


Vayu Robins
 Share

Recommended Posts

Hi.

I am trying to add an extra input  field to the FileInputField. I have modified the ImageExtra module. http://modules.processwire.com/modules/image-extra/. I would like to use the InputfieldPageAutocomplete field to add users. However the layout seems wrong and when typing, nothing is suggested, it doesn't find a user. Here is the code I have used:

protected function renderUserItemField(Pagefile $pagefile, $id, $n, $current) {
    $fieldName = $current . '_' . $id;
    $field = $this->modules->get('InputfieldPageAutocomplete');
    $field->setAttribute('name+id', $fieldName);
    $field->setAttribute('parent_id', 29);
    $field->startLabel = $this->_('Partner');
    $out .= $field->render();
    return $out;
}

I have attached a screenshot of how it is rendered on the page. I hope someone can help me.

post-3258-0-33044200-1442992620_thumb.pn

Link to comment
Share on other sites

Hi adrian.

Thanks for helping. No, the InputfieldPageAutocomplete.min.js is not loaded on this page, and this could of course be the problem. I will look into how I can do this. If there is a certain way to do this in processwire backend, then please let me know. I will try to search for this.

Link to comment
Share on other sites

Hi adrian.

Thanks for helping. No, the InputfieldPageAutocomplete.min.js is not loaded on this page, and this could of course be the problem. I will look into how I can do this. If there is a certain way to do this in processwire backend, then please let me know. I will try to search for this.

Often you just need to do this:

public function init() {
    parent::init();
}

The parent::init() is the trick.

Here is a comprehensive discussion on it:

https://processwire.com/talk/topic/1416-inputfieldmodule-doesnt-autoload-their-jscss/

Link to comment
Share on other sites

Thanks again! Unfortunately it did not work. The module does not extend Inputfield, Process or ModuleJS. However, I was able to load the files like this:

public function init() {
	wire('config')->styles->append("/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.css");
	wire('config')->scripts->append("/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.min.js");
}

But loading these files did not fix the problem, so the InputfieldPageAutocomplete still does not work.

Link to comment
Share on other sites

Actually, it does extend Inputfield: 

https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module#L15

but since you are using it from a different module it doesn't know to autoload these because they are not in the same folder as your new module.

I think you might need to share the code for your new module so we can see where things might be going wrong.

Link to comment
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...