Custom Options from serverList in event form

Hi,

I read other posts on the subject but I was not able to make them work. I want to have options in a custom field of type “select” in the event form to be populated by a list built on the server side.

In the back-end of Joomla, in the Scheduler component, I have added a custom field of type “select”;

Name: membre
Description: membre
Type: “Select list”

In the file named " scheduler_include.html", I added this code;

Hi,
you should call

$MembreList = new OptionsConnector($this->connection);
$MembreList ->render_table("ASJ273_users", "id", "username");
$this->scheduler->set_options("membre", $MembreList );

before render-call of scheduler connector inside getEventsRec method.

Attached event beforeRender is called for each item and already after render started, so setting options after that doesn’t make sense.

Hi,

Thank you for your help. I look at my code and putted it in the first list of the function getEventsRec. It did not work. Then in the file I use in “scheduler_include.html” I used an other system list username and it did not work too… this permits to limit the scope of me investigation, but still it is not working.

Do you have anyu clues!?!? Did I mist something?

JR

Hi,

  1. you should modify your connector at server side a little:
public function getEventsRec($usergroups) {
		require("connector/scheduler_connector.php");
		$this->scheduler = new schedulerConnector($this->connection);
		
		$MembreList = new OptionsConnector($this->connection);
		$MembreList ->render_table("ASJ273_users", "id", "username(value),username(label)");
		$this->scheduler->set_options("membre", $MembreList);

		if ($this->settings['settings_debug'] == 'true') {
  1. Try to replace your code in scheduler_include.html with the follow:
<script>

	scheduler.attachEvent("onXLS", function() {
		for (var i = 0; i < scheduler.config.lightbox.sections.length; i++) {
			if (scheduler.config.lightbox.sections[i].name === "membre")
				scheduler.config.lightbox.sections[i]= {
					name: "membre",
					type:"select",
					map_to: "membre",
					options: scheduler.serverList("membre"), 
					focus: true
				};
		}
	});

</script>
  1. Make sure that your custom field name is “membre” and its type is “select”.