Jump to content

InputfieldPage: Not fully configured / currently nonfunctional


Harmster
 Share

Recommended Posts

Hey,

I am trying to create a template with a field with the type page from a module using the API.

This is some of the code I use to generate the field and the template.

The field

$mvc_register_field = $this->fields->get('mvc_register_page_id');
if(!$mvc_register_field->id){
   $mvc_register_field = new Field();
   $mvc_register_field->name = 'mvc_register_page_id';
   $mvc_register_field->label = 'MVC Register Page ID';
   $mvc_register_field->description = 'Checkbox that enables MVC for a page';
   $mvc_register_field->type = 'FieldtypePage';
   $mvc_register_field->save();
}

And the template

if(!$this->templates->mvc_register){
   $t = new Template();
   $t->name = 'mvc_register';
   $fieldgroup = $this->fieldgroups->get($t->name);
   if(!$fieldgroup->id){
      $fieldgroup = new Fieldgroup();
      $fieldgroup->name = $t->name;
      $fieldgroup->add($this->fields->get('mvc_register_page_id'));
      $fieldgroup->save(); 
   }
   $t->fieldgroup = $fieldgroup;
   $t->roles = array($this->roles->get('superuser')->id);
   $t->save();
}

And this is how i try to create a page

$controller_registry = new Page();
$controller_registry->template = $this->templates->get('mvc_register');
$controller_registry->parent = $this->pages->get("name=" . self::PAGE_NAME);
$controller_registry->title = $controller_name;
$controller_registry->name = $controller_name;
$controller_registry->mvc_register_page_id = $this->pages->get('url=page_url');
$controller_registry->save();

Which gives me this error:

InputfieldPage: Not fully configured / currently nonfunctional (mvc_register_page_id)

How do I resolve this?

Link to comment
Share on other sites

In a bit of a rush, so not sure if this is definitely right, but saw your question and thought this might help:

https://github.com/adrianbj/ProcessPageFieldSelectCreator/blob/master/ProcessPageFieldSelectCreator.module#L377

It seems like you are missing some config options in your page field, possibly the parent_id and/or template_id - these are what you would set on the Input tab when creating a page field through the admin.

Hope that helps. 

Link to comment
Share on other sites

Ok that sounds fair, however I have no idea what values I should put there? 

Page Inputfileds have to have directions on what pages should be selectable. Only you can know what pages you want to be selectable. The most common scenario is all pages having a certain parent. In that case, you'd set the parent_id property to be the ID of the parent page having those children. Another common scenario is all pages using a certain template, in which case template_id would be the property you'd want to set. There are also other options, like findPagesSelector where you specify a selector string to find the pages that should be selectable. If you'd like you can create+configure the field how you want it in Setup > Fields, then view the entry in PhpMyAdmin in table fields column data to see what options it stored. 

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

×
×
  • Create New...