What are attribute sets used for and how.
Permalink
I am still trying to understand what attribute sets are used for, how they are used, and whether attribute sets for Members, pages, and files are the same thing or three different sets altogether?
I am modifying a custom version of the register form that I hope I may use an attribute set to select which attributes get placed in the registration form based on the user group that I will programmatically pre-assign that user. I am still researching documentation to figure this out but I would appreciate any input I can get.
I created an attribute set with the dashboard under Members > Attributes > Manage Sets in the upper right. I then selected the set that I just created and populated it with all the attributes for that specific user that is registering. Now, all of these attributes show up in the registration form. My goal is to be able to pre-select the attribute set for that user's registration based on the group that will be pre-ssigned to that user when the registration form is loading. I want to ultimately have the same registration form register all users but give each user a specific set of data(attributes) stored for each user based on which registration group they are pre-assigned to.
All thoughts are welcome.
I am modifying a custom version of the register form that I hope I may use an attribute set to select which attributes get placed in the registration form based on the user group that I will programmatically pre-assign that user. I am still researching documentation to figure this out but I would appreciate any input I can get.
I created an attribute set with the dashboard under Members > Attributes > Manage Sets in the upper right. I then selected the set that I just created and populated it with all the attributes for that specific user that is registering. Now, all of these attributes show up in the registration form. My goal is to be able to pre-select the attribute set for that user's registration based on the group that will be pre-ssigned to that user when the registration form is loading. I want to ultimately have the same registration form register all users but give each user a specific set of data(attributes) stored for each user based on which registration group they are pre-assigned to.
All thoughts are welcome.
Thanks for responding. I am now using this Registration list to add the attributes as fields to the form but it is all the user attributes and there is no key/value pair in these attribute's attributes** that pertains to groups or even the set they are assigned to. The akID to asID is in a separate table. I need to find the proper method that filters attributes by the set they belong to.
I am also looking for and having difficulty finding it is where the default group(Basic) is being assigned to the registering user, capture it, and replace it with the proper group ID before the form is submitted and the user registered.
Any help here is appreciated.
Tom S.
** I think the term attributes in c5 is grossly overused and therefore an undefinable term as far as c5 goes. This term is confusing to us who are still trying to figure c5 out. Everything has a list of attributes, even attributes have attributes.
I am also looking for and having difficulty finding it is where the default group(Basic) is being assigned to the registering user, capture it, and replace it with the proper group ID before the form is submitted and the user registered.
Any help here is appreciated.
Tom S.
** I think the term attributes in c5 is grossly overused and therefore an undefinable term as far as c5 goes. This term is confusing to us who are still trying to figure c5 out. Everything has a list of attributes, even attributes have attributes.
I found your response to another post,http://www.concrete5.org/community/forums/usage/specific-attributes... I'm using it for setting the attributes to the form. Now, all I need to do is figure out how to set the user's group from the default to the group that the form relates to.
There is a problem with this. While this sets only the form fields for the attributes needed for the group , the form validation is trying to validate all attributes that were marked 'required' and not just the ones on the form.
There is a problem with this. While this sets only the form fields for the attributes needed for the group , the form validation is trying to validate all attributes that were marked 'required' and not just the ones on the form.
if($_POST['Group'] == "Basic") { $set = AttributeSet::getByHandle('basic'); } elseif($_POST['Group'] == "Subscriber") { $set = AttributeSet::getByHandle('subscribers'); } else { echo '<h3>Group not found!</h3><br />'; } if(is_object($set)){ $FormAttribs = $set->getAttributeKeys(); } foreach($FormAttribs as $ak) { $HTML = $af->display($ak, $ak->isAttributeKeyRequiredOnRegister()); foreach($ak as $key=>$value) { if (($key == 'atHandle') && ($value == 'boolean')) { $HTML = '<div class="Checkboxes">';
Viewing 15 lines of 34 lines. View entire code block.
You can use the same idea for validation. As you can see in the controller file, it is using a validation method for each $uak in the loop. So just modify the $array that's being looped, just like you did for displaying.
$uak->validateAttributeForm();
$uak->validateAttributeForm();
Excelent!
In the form controller, I replaced;
with the following and now my form seems to be set up properly;
I went back for final testing and I still have an issue with the code failing if there is an error in form completion and the page is reloaded with error messages. My code is relying on the group name that was posted by the previous page to the form. When the page is re-loaded from an entry error in the form, I lose the Group name from the original posting and the form no longer works. I need a way to have the group name survive a page reload. I don't care for the method of storing it to a cookie. That adds another point of failure which is the client.
Actually, my problem is greater than that. I am dynamically loading in extra fields on the form that are the form fields posted by the previous page. When the form page is re-loaded, I also loose these fields on the form because the previous post is lost. Is there any way to post the previous post back to the page when it's re-loaded as a result of a form error?
I am grateful for Any ideas.
Thanks
In the form controller, I replaced;
$aks = UserAttributeKey::getRegistrationList();
with the following and now my form seems to be set up properly;
I went back for final testing and I still have an issue with the code failing if there is an error in form completion and the page is reloaded with error messages. My code is relying on the group name that was posted by the previous page to the form. When the page is re-loaded from an entry error in the form, I lose the Group name from the original posting and the form no longer works. I need a way to have the group name survive a page reload. I don't care for the method of storing it to a cookie. That adds another point of failure which is the client.
Actually, my problem is greater than that. I am dynamically loading in extra fields on the form that are the form fields posted by the previous page. When the form page is re-loaded, I also loose these fields on the form because the previous post is lost. Is there any way to post the previous post back to the page when it's re-loaded as a result of a form error?
I am grateful for Any ideas.
Thanks
You the user that registers himself can choose a group? Is that what you're saying?
If not, you could save it in a SESSION variable.
If so, you should use the $form helper which takes care of post data persistence.
If not, you could save it in a SESSION variable.
If so, you should use the $form helper which takes care of post data persistence.
Hi again, akodde.
The following is a detailed explanation of what I am working on;
My intent for this form is to make it universal for different types of users who are registering. Right now, I have two different user groups that will use it, "Basic' and Subscriber'. I want it to accommodate the standard registration for basic site users and also, if the guest selects to subscribe to my service, it will place the different fields on their registration form that are required for their service account. This is dependent on the page that directed them to this registration page. If they click on 'Register' in the home header bar, no group name will be posted to to the form and the default, 'Basic' group will be used. If they are sent to this registration page by following a line of service sign up pages, the 'Order-Confirm' page will post their list of selected options along with the group, 'Subscriber' for inclusion in the form. Also, this is where the user attributes for that group are included based on the group it receives in the posting.
Using session variables is something that I am trying to avoid. Posting to cookies on the guest's browser for me is a last resort. I'll use them if I have to but I would like to keep all mission critical stuff on the server side.
After playing with this a little more last night, I am not so sure that I am loosing the group variable as a result of a page re-load. I am loosing it after the re-load in the 'do_register' method but I'm finding it persistent in other methods of the controller. I'm now wondering if c5 is doing an automatic re-posting of the original post when it re-loads the page on errors and my loss in 'do_register' method is as a result of something else.
I really appreciate your dialog with me on my issues. Discussing them with someone helps me clarify my issues and add insight with alternative thinking.
Thanks,
Tom Strike
The following is a detailed explanation of what I am working on;
My intent for this form is to make it universal for different types of users who are registering. Right now, I have two different user groups that will use it, "Basic' and Subscriber'. I want it to accommodate the standard registration for basic site users and also, if the guest selects to subscribe to my service, it will place the different fields on their registration form that are required for their service account. This is dependent on the page that directed them to this registration page. If they click on 'Register' in the home header bar, no group name will be posted to to the form and the default, 'Basic' group will be used. If they are sent to this registration page by following a line of service sign up pages, the 'Order-Confirm' page will post their list of selected options along with the group, 'Subscriber' for inclusion in the form. Also, this is where the user attributes for that group are included based on the group it receives in the posting.
Using session variables is something that I am trying to avoid. Posting to cookies on the guest's browser for me is a last resort. I'll use them if I have to but I would like to keep all mission critical stuff on the server side.
After playing with this a little more last night, I am not so sure that I am loosing the group variable as a result of a page re-load. I am loosing it after the re-load in the 'do_register' method but I'm finding it persistent in other methods of the controller. I'm now wondering if c5 is doing an automatic re-posting of the original post when it re-loads the page on errors and my loss in 'do_register' method is as a result of something else.
I really appreciate your dialog with me on my issues. Discussing them with someone helps me clarify my issues and add insight with alternative thinking.
Thanks,
Tom Strike
Hi again,
I tried all methods possible now except your suggestion of using SESSIONS. When you suggested it, a sessions cookie came to mind and didn't think that php also provided a sessions manager.
As you suggested, after trying everything else, I am now using php sessions for this to store the original post to this page. I need to unset the session variable whenever this Registration page is left but not reloading the view as when an error in validation occures.
Question 1: When the Registration page reloads itself, does it call on the Dispatcher to do so?
Question 2: If so, is there a place in the Dispatcher that determines that a page is reloading itself?
Question 3: If so, is there a hook in the Dispatcher that can be used to unset or not unset my session variable?
Can you or anyone reading this suggest an approach to this problem?
Thanks,
Tom S.
I tried all methods possible now except your suggestion of using SESSIONS. When you suggested it, a sessions cookie came to mind and didn't think that php also provided a sessions manager.
As you suggested, after trying everything else, I am now using php sessions for this to store the original post to this page. I need to unset the session variable whenever this Registration page is left but not reloading the view as when an error in validation occures.
Question 1: When the Registration page reloads itself, does it call on the Dispatcher to do so?
Question 2: If so, is there a place in the Dispatcher that determines that a page is reloading itself?
Question 3: If so, is there a hook in the Dispatcher that can be used to unset or not unset my session variable?
Can you or anyone reading this suggest an approach to this problem?
Thanks,
Tom S.
Hi Tom,
Yes, you can hook into these steps (called 'Events'). Here is a list of the available events:http://www.concrete5.org/documentation/developers/system/events...
Yes, you can hook into these steps (called 'Events'). Here is a list of the available events:http://www.concrete5.org/documentation/developers/system/events...
WOW! Thank You, Thank You, Thank You.
This is the part of c5 that I only thought should exist but wasn't able to find in all the time that I've been working with c5. This is a big chunk of c5's functionality and now I have to completely re-think my approach to projects. Even the page you supplied the link to doesn't tell the full story. When I opened the site_events.php file, I found that the dashboard had already used this file to set the default group which means that another Model file isn't even needed. For adding miscellaneous methods, one only needs to put a short class in the site_events.php file itself and be done with it. My work is already half way done with the class that the dashboard has provided. A few modifications, and additions to this and my registration form should be working.
One thing to note though, it's to bad there isn't a short-cut events extender for single pages.
Thanks again,
Tom S.
This is the part of c5 that I only thought should exist but wasn't able to find in all the time that I've been working with c5. This is a big chunk of c5's functionality and now I have to completely re-think my approach to projects. Even the page you supplied the link to doesn't tell the full story. When I opened the site_events.php file, I found that the dashboard had already used this file to set the default group which means that another Model file isn't even needed. For adding miscellaneous methods, one only needs to put a short class in the site_events.php file itself and be done with it. My work is already half way done with the class that the dashboard has provided. A few modifications, and additions to this and my registration form should be working.
One thing to note though, it's to bad there isn't a short-cut events extender for single pages.
Thanks again,
Tom S.
You may find the 'Event Tester' addon by mnkras useful (free). As well as being good for seeing when events fire, it also contains some good built in documentation on events generally.
Thanks. I'll look into that.
Hi Guys, picked this thread up and am looking at getting quick nudge in the right direction.
I am looking to "print" the User Attribute Set's Titles on the Registration form that I am building today. I have the register.php file open and have tried a couple of things, but rather than buy an add-on, thought it best to find a coded solution i.e a small snippet of php to bring this information onto the page.
Any help would be great.
Ben.
I am looking to "print" the User Attribute Set's Titles on the Registration form that I am building today. I have the register.php file open and have tried a couple of things, but rather than buy an add-on, thought it best to find a coded solution i.e a small snippet of php to bring this information onto the page.
Any help would be great.
Ben.
It basically does $attribs = UserAttributeKey::getRegistrationList();
What you can do is $attribs = UserAttributeKey::getList() and then loop them to check the corresponding attribute set of each attribute. You can use the function $ak->inAttributeSet() for that.