SIERRA Posted June 12, 2018 Share Posted June 12, 2018 I have a repeater field called 'class_offerings'. In this I am having the fields class_offering_title, teacher_name and term I would like to populate a drop down with non empty unique values available in teacher_name. I' m using below code. But this is displaying with duplicates. Could you please suggest on this. Thanks <?php $list_teacher=$page->class_offerings->find("teacher_name!='', sort=teacher_name"); $list_teacher_unique=$list_teacher->unique(); foreach($list_teacher_unique as $class_teachername) {?> <option value="<?php echo $class_teachername->teacher_name;?>"><?php echo $class_teachername->teacher_name->title;?></option> <?php }?> Link to comment Share on other sites More sharing options...
SIERRA Posted June 12, 2018 Author Share Posted June 12, 2018 (edited) I have changed the field type as option and included the needed values. So I can able to populate as below. Now this is working as expected. Thanks <?php $get_field = $fields->get('teacher_name'); $field_options = $get_field->type->getOptions($get_field); foreach($field_options as $option) { echo $option->id; } ?> Edited June 12, 2018 by SIERRA Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now