Jump to content

Programatically adding a page to FieldtypePage field


lenno
 Share

Recommended Posts

Dear all,

I have a presumably simple question, which I simply can't find the answer for.

I need to programatically add a page to a FieldtypePage field. I tried the following:

$page->a_field_of_fieldtype_page->add($anotherPage);

but without success.

Can anybody help?

Link to comment
Share on other sites

Try turning off output formatting before setting values of fields, and also don't forget to save.

$page->of(false); // turn of output formatting
$page->a_field_of_fieldtype_page->add($anotherPageOrID);
$page->save();

Or if your pagefield is set to a single value:

$page->of(false); // turn of output formatting
$page->a_field_of_fieldtype_page = $anotherPageOrID;
$page->save();

 

  • Like 3
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

×
×
  • Create New...