Render Select attribute form

Permalink
Hi all

I'm trying to render a select attribute form (like you see in a page's properties if you have a select page attribute) which shows all the available values for a particular attribute. I don't want to process them with the API (i'm doing that with a custom function) - I just want to display them.

I've gone through the docs and searched and searched to no avail.

Any ideas?

melat0nin
View Replies:
ScottC replied on at Permalink Reply
ScottC
sure.
$object // an instance of a CollectionAttributeKey
$aValues are your default values
echo $object->render('form', $aValues, true);
melat0nin replied on at Permalink Reply
melat0nin
Cool, that works to render the text input, but the ajax stuff that loads in the values as the user types is missing - is there an additional helper I need to load? I'm displaying this form in the edit dialog of a block.

edit: actually the script is called when text is entered (I can see this in Firebug's Net panel), but nothing shows up as a suggestion. The script response is correct as well, but the values aren't then passed into the input field.
ScottC replied on at Permalink Reply
ScottC
err
$page = Page::getCurrentPage(); //or populate it from your tool request call on any page
$aValues = $page->getAttributeValueObject($object);


sorry, try that.
melat0nin replied on at Permalink Reply
melat0nin
Hmm I'm not trying to read the current page's attributes (it doesn't have any) - what I want to do is get a list of the possible values which the user can choose from, and which will be stored in a custom database field (the attribute won't be set at all - just the text value will be saved in my customised block's table).

The reason for using attributes is I need to apply them to some pages, but i'm storing the same information for non-pages (map entries) so I want the text to be identical, hence using the attribute helper to select them.
ScottC replied on at Permalink Reply
ScottC
Try to search for SelectAttributeController, there's a function on it after you get an instance of an attribute key that will give you its options.
melat0nin replied on at Permalink Reply
melat0nin
I had a look through the API docs but no joy :(

EDIT: I've got the list using the code from this post (http://www.concrete5.org/community/forums/customizing_c5/get-list-of-custom-page-attribute-values-select-list/) but rendering the AJAX interface is proving elusive..
tudorsv replied on at Permalink Reply
$at_cat = AttributeKeyCategory::getByHandle('collection');
$at_key = $at_cat->getAttributeKeyByHandle('your_at_key_handle');
$at_key_id = $at_key->getAttributeKeyID();

$at_key->render('form');
$at_key->outputSearchHTML(); //similar to render