Jump to content
alejandro

How to push new item in field type options?

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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 ?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...