public function __construct(field_collection $fields, collection $source_data) { $final_fields = []; $this->source_data = $source_data; $fields->iterate(function (filter $field) use(&$final_fields, $source_data) { $values = $source_data->filter_unique($field); $new_field = form::create('field_checkboxes', $field->inner_field()->field_name, $values); $new_field->original_field = $field->inner_field(); $new_field->label = $field->title; $final_fields[] = $new_field; }); $final_fields[] = form::create('field_string', 'identifier')->set_attr('hidden', true); parent::__construct($final_fields); }
/** * @param array $fields * @param array $options * @return field_collection */ public static function get_all(array $fields, array $options = []) { $array = new field_collection(); $array->get_all('\\object\\filter', $fields, $options); return $array; }