neildaemond Posted February 22, 2013 Share 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 Link to comment Share on other sites More sharing options...
diogo Posted February 22, 2013 Share Posted February 22, 2013 The module is FieldtypePage. I'm not sure how to configure the field options... Link to comment Share on other sites More sharing options...
Soma Posted February 22, 2013 Share 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 Link to comment Share on other sites More sharing options...
diogo Posted February 22, 2013 Share Posted February 22, 2013 Soma, but how do you define the input field type? Link to comment Share on other sites More sharing options...
apeisa Posted February 22, 2013 Share 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 Link to comment Share on other sites More sharing options...
diogo Posted February 22, 2013 Share Posted February 22, 2013 I didn't see the second example before... Soma, didn't you edit your answer? 1 Link to comment Share on other sites More sharing options...
apeisa Posted February 22, 2013 Share Posted February 22, 2013 Of course he edited, it's a trademark Link to comment Share on other sites More sharing options...
diogo Posted February 22, 2013 Share Posted February 22, 2013 You sneaky you... Link to comment Share on other sites More sharing options...
neildaemond Posted February 22, 2013 Author Share 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. Link to comment Share on other sites More sharing options...
Soma Posted February 22, 2013 Share 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. Link to comment Share on other sites More sharing options...
Soma Posted February 22, 2013 Share 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... 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