Checkboxes - Custom Registration Attributes
Permalink
Hi All,
I've setup the attribute content within Concrete5 and have used the following code to display the checkbox in the registration:
However, once clicked, it is not saving the value as a user attribute. Any ideas on this?
Also, I want to be able to code in a select box, however I cant find much documentation regarding this?
Concrete5 Version 5.6.x
Thanks
I've setup the attribute content within Concrete5 and have used the following code to display the checkbox in the registration:
However, once clicked, it is not saving the value as a user attribute. Any ideas on this?
Also, I want to be able to code in a select box, however I cant find much documentation regarding this?
Concrete5 Version 5.6.x
Thanks
Are you trying to use these within the standard C5 registration form? If so, why aren't you just checking the boxes in the dashboard for show on registration form?
No, this is a completely custom registration form. Overriding the default one.
I think you have a couple of things missing in your code, I believe it should be like this:
The form helper for creating a checkbox is like this
So what I have there will make the value 1 which is usually the case when you are using a checkbox (boolean) attribute.
The form helper for creating a checkbox is like this
$form->checkbox($name, $value, $isChecked, $tagAttributes);
So what I have there will make the value 1 which is usually the case when you are using a checkbox (boolean) attribute.
Thanks for the explanation. I see what was happening now!
Could you explain the correct format for the select box at all? I cant seem to get that to even show on the registration form!
Could you explain the correct format for the select box at all? I cant seem to get that to even show on the registration form!
Take a look at this page of the Documentation, it shows how to setup each of the types.
https://www.concrete5.org/documentation/developers/5.6/forms/standar...
https://www.concrete5.org/documentation/developers/5.6/forms/standar...
Hi,
For the select, do you have any idea why the following wont save?
Same format as the documentation
For the select, do you have any idea why the following wont save?
<fieldset> <div> <?php $event = 'akID[' . UserAttributeKey::getByHandle('event')->getAttributeKeyID() . '][value]'; ?> <?php echo $form->label($event, t('Select Event Type'))?> <?php echo $form->select($event, array('SOCIAL LEISURE' => 'Social Leisure', 'CHARITY' => 'Charity'), 'CHARITY');?> </div> </fieldset>
Same format as the documentation
Is your attribute a Select Attribute or is it a text attribute? If it is a select attribute you have to jump through some hoops to match up the select options.
Its a select attribute, but it can be a text attribute to make it work? This is located within the "Edit Profile" section. I read about setAttribute() playing apart here but still unable to get it working!
I also cant get the select attribute to work in the Registration? I'm not sure why concrete5 have made a custom select attribute so long winded to program?
The problem with the select attribute is the naming convention, it should look like this
Make sure that these are in the exact same order as the options in the dashboard in order to verify that the option values match up correctly.
I agree with you that this is not very programmer friendly, but you always have the option to manually update the user attribute in the controller rather than trying to replicate the standard functionality.
Make sure that these are in the exact same order as the options in the dashboard in order to verify that the option values match up correctly.
I agree with you that this is not very programmer friendly, but you always have the option to manually update the user attribute in the controller rather than trying to replicate the standard functionality.
Tried this code also and it still doesnt want to work! This is the exact same as my dashboard attribute:
and this translate to the following in the code source
I have also added "Required on Registration" and this error message appears every time as its obviously not receiving a value!
I can't believe a select box is so difficult compared with the other input options!
and this translate to the following in the code source
<div> <select name="akID[30][atSelectOptionID][]" id="akID[30][atSelectOptionID]1" ccm-passed-value="No" class="ccm-input-select"><option value="No" selected="selected">No</option><option value="Yes" >Yes</option></select> </div>
I have also added "Required on Registration" and this error message appears every time as its obviously not receiving a value!
I can't believe a select box is so difficult compared with the other input options!
Tried this and altering it a few times, but still can't seem to get it to work. Does it matter which version of Concrete5 im runing? Its 5.6 not 5.7
Please provide a screenshot of the attribute setup in the Dashboard and the exact code snippet that you have on the front end.
That all appears to be correct, the only other thing I can think of is that the select option ids aren't 0 and 1, the only way to check that would be to go into the Dashboard edit screen and open your developer tools and see what the id is from there.
Dashboard Edit Screen - > Developer Tools? Where would that be on 5.6? Im guessing that is a 5.7 thing?
It's a browser thing, like if you're using Firefox there is Firebug, if you are using Chrome hit F12 and the Developer Tools will come up.
Oh Sorry - I usually call it "inspect element". Indeed the ID's were different, this is the code that is produced when you set it to concrete5's default
and this is the code that is output when I use a custom way as you stated above
<select name="akID[30][atSelectOptionID][]" id="akID[30][atSelectOptionID]1" ccm-passed-value="8" class="ccm-input-select"><option value="" >** None</option><option value="7" >No</option><option value="8" selected="selected">Yes</option></select>
and this is the code that is output when I use a custom way as you stated above
<label for="akID[30][atSelectOptionID][]" class="control-label">Are you a Supplier? </label><a data-toggle="modal" data-target="#supplierModal"><i class="fa fa-info-circle fa-1x"></i></a></i><br/> <select name="akID[30][atSelectOptionID][]" id="akID[30][atSelectOptionID]1" ccm-passed-value="7" class="ccm-input-select"><option value="7" selected="selected">No</option><option value="8" >Yes</option></select>
That looks like it should work to me. Does it?
It did! However, I also had to click "Show on Registration Form.", which normally brings up concrete5's default selectbox, but for some reason it doesnt now. Im guessing this is because of the correct values? Thanks for your help, much appreciated!