Jump to content

create pagearray field with api? (multipage select field?)


neildaemond
 Share

Recommended Posts


Quick question for anyone who is familiar with it..

If creating a new text field with the api looks something like this:

$nf = new Field();  

$nf->type = $this->modules->get(FieldTypeText);

$nf->save();

Then how would I create that field which allows me to select multiple pages (which module do I get and set type as)

I usually just choose from modules under wire/modules/Fieldtype. But, in this case I'm not sure which one it is.

I know I could dereference any pagearray as a string and save the pipe delemited string to the text field, but I'd liek to have the pageselect functionality in the admin.

Thanks In Advance

Link to comment
Share on other sites

$f = new Field();
$f->type = $this->modules->get("FieldtypePage");
$f->name = 'mypageselect';
$f->label = 'Select Page';
$f->derefAsPage = FieldtypePage::derefAsPageOrNullPage;
$f->inputfield = 'InputfieldPageListSelect';
$f->save();
 

or

$f->derefAsPage = FieldtypePage::derefAsPageArray;
$f->inputfield = 'InputfieldAsmSelect';

etc

  • Like 3
Link to comment
Share on other sites

The module is FieldtypePage. I'm not sure how to configure the field options...

I'm trying to do my field creations with the api but I never know how to configure the field options either. Is there any documentation for this?

$f = new Field();
$f->type = $this->modules->get("FieldtypePage");
$f->name = 'mypageselect';
$f->label = 'Select Page';
$f->derefAsPage = FieldtypePage::derefAsPageOrNullPage;
$f->inputfield = 'InputfieldPageListSelect';
$f->save();
 

or

$f->derefAsPage = FieldtypePage::derefAsPageArray;
$f->inputfield = 'InputfieldAsmSelect';

etc

thanks, wow I would have never of guessed.

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...