neildaemond Posted February 22, 2013 Posted February 22, 2013 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
diogo Posted February 22, 2013 Posted February 22, 2013 The module is FieldtypePage. I'm not sure how to configure the field options...
Soma Posted February 22, 2013 Posted February 22, 2013 $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 3
diogo Posted February 22, 2013 Posted February 22, 2013 Soma, but how do you define the input field type?
apeisa Posted February 22, 2013 Posted February 22, 2013 $f->inputfield, just like soma has in his examples. Or what do you mean Diogo? Here are few more examples: https://github.com/apeisa/CustomPageRoles/blob/master/CustomPageRoles.module#L198
diogo Posted February 22, 2013 Posted February 22, 2013 I didn't see the second example before... Soma, didn't you edit your answer? 1
neildaemond Posted February 22, 2013 Author Posted February 22, 2013 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.
Soma Posted February 22, 2013 Posted February 22, 2013 Theres a documentation directly in core. Just look at what options a fieldtype has by looking at the code in wire modules.
Soma Posted February 22, 2013 Posted February 22, 2013 I didn't see the second example before... Soma, didn't you edit your answer? It's already there in the first example...
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