alejandro Posted February 23, 2016 Share Posted February 23, 2016 Hello, if I have an options field type: $field->months And I need to push several new items like: for ($i=0; $i < (date("n")); $i++) { $field->months->push($i); // or $field->months->and($i); } But all of this returns an error "... not an allowed type..". As i understand an options field type is a WireArray so it should support such methods? Thanks, Alejandro. Link to comment Share on other sites More sharing options...
alejandro Posted February 23, 2016 Author Share Posted February 23, 2016 Well, I figured a way: $array = array(); for ($i=0; $i < (date("n")); $i++) { $array[] = $i; $field->months = $array; } But, just for the knowledge, is there a way to add $array to $field->months ? Link to comment Share on other sites More sharing options...
adrian Posted February 23, 2016 Share Posted February 23, 2016 I haven't tried, but I don't think there is an "add" method for the options fieldtype. Did you read here: https://processwire.com/api/modules/select-options-fieldtype/#manipulating-options-on-a-page-from-the-api Also, shouldn't your: $field->months = $array; be outside the "for" loop? Link to comment Share on other sites More sharing options...
alejandro Posted February 23, 2016 Author Share Posted February 23, 2016 I haven't tried, but I don't think there is an "add" method for the options fieldtype. Did you read here: https://processwire.com/api/modules/select-options-fieldtype/#manipulating-options-on-a-page-from-the-api Also, shouldn't your: $field->months = $array; be outside the "for" loop? Yeah, it should 1 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