Save page attribute data from custom form

Permalink 1 user found helpful
I am creating a custom form that can add/edit a page. This is being done to provide extra instructions and additional organization to the page authors that cannot be done using composer.

I can generate the page attribute label and form field using existing methods:
$page = Page::getByID(123); // This is the page I want to update
$handle = 'my_page_attribute'; // This is the page attribute's handle
// Get the attribute
$ak = CollectionAttributeKey::getByHandle($handle);
// Display the attribute label
echo $ak->render('label');
// Display the attribute form control
echo $ak->render('form',$page->getAttributeValue($handle),true);

Unfortunately, this outputs the fields with names and IDs that are difficult to work with (i.e. akID[46][value]).

Concrete5.6 used to have a method that made saving page attributes easy. You just called the

Is there anything like this in Concrete5.8? If not, how do I save a multitude of page attributes that are rendered using the $ak->render() method?

View Replies: View Best Answer
pvernaglia replied on at Permalink Best Answer Reply
I am doing something similar in a Single Page Controller:

To display the attribute
$ak = CollectionAttributeKey::getByID($optAtt);
$value = $page->getAttributeValueObject($ak);
echo $ak->render('form', $value, true);
to Save the attribute
$ak = CollectionAttributeKey::getByID($key);
$controller = $ak->getController();
$value = $controller->createAttributeValueFromRequest();
$editPage->setAttribute($ak, $value);