Render attribute with "default" value
Permalink
Hi,
I'm stuck...
I have multiple collection attributes in a block-form.
It saves perfectly and works in my view, but when I want to edit the block I can't seem to load the attribute with the saved values from the block.
I would like to do the following:
How do I get this to work?
Best,
Corretje
I'm stuck...
I have multiple collection attributes in a block-form.
$ak->render('form');
It saves perfectly and works in my view, but when I want to edit the block I can't seem to load the attribute with the saved values from the block.
I would like to do the following:
$ak->render('form', $my_value);
How do I get this to work?
Best,
Corretje
Hi,
Thanks for answering!
Is there a way that I can "create" the AttributeValueObject based on a string or int?
Thanks for answering!
Is there a way that I can "create" the AttributeValueObject based on a string or int?
Yes but it's not straightforward because each attribute type has a different value object.
For instance the address attribute has different properties for each part of the address.
The select attribute is a bit of a monster with an option list object and option item objects
For instance the address attribute has different properties for each part of the address.
The select attribute is a bit of a monster with an option list object and option item objects
Any example code?
I've been trying this for 2 days now, but I can't seem to make it happen... :(
Thanx
I've been trying this for 2 days now, but I can't seem to make it happen... :(
Thanx
If you look at any attribute in the core, inside its controller there's a method createAttributeValue($value) that shows you how to do it for each attribute type.
Some are pretty simple like the Boolean attribute and others like the Select attribute are a pain in the neck
Some are pretty simple like the Boolean attribute and others like the Select attribute are a pain in the neck
The proper value is not a string or anything like that, it is a value object for the attribute.
Say your attribute is attached to a Page object $page.
You would do $my_value = $page->getAttributeValueObject($ak);