Show particular form elements depending on new/edit


I’d like to be able to show a ‘combo’ field if the event is new (the ‘+’ button was clicked), or a read-only ‘text’ field if editing an existing event.

I assume it’s down to having both defined in scheduler.config.form[] with one hidden. I have the combo loading data and working fine.

Which event should I target, and what property should I access to figure out if it’s a new event (would it be $$(“scheduler”).getCursor() or something else?), and is using ‘hidden’ the best way to do this?

Many thanks!


try something like so:


That’s great! The next part of this problem is that the field we’re talking about is the “text” field. How do I name both elements ‘text’ without conflicts?

Thanks so much!

How do I name both elements ‘text’ without conflicts?

Unfortunately, it is impossible to use one name or id for multiple elements.

Would it work if I had a datastore of some kind that was named ‘text’, and then use that to load the data into and out of the two (differently named) fields?

You can set extraParser function. It will be called for each data item

$$(“scheduler”).data.extraParser =function(data){
data.text1 = data.text;
data.text2 = data.text;

text1 and text2 will be available using the following:

var itemId = $$(“scheduler”).getCursor(); // id of the selected item
var data = $$(“scheduler”).item(itemId);
$$(“scheduler”).item(itemId).text1 = “…”;

Both new fields will be sent with the save requests. The example of php script

function do_before_save($action){
$text1 = $action->get_value(“text1”);
$text2 = $action->get_value(“text2”);


Thanks for the above.

I’ve ended up taking making a different solution. The field with id ‘text’ is the combo, and I have a field of type ‘text’ with ID of clientname.

Your hide()/show() code above is working great.

What I’m doing is watching for a cursor change and updating the ‘client’ field with the following:

$$("scheduler").attachEvent("onAfterCursorChange", function(id){ var clientID = getClientIDFromEventID(id); var clientFullName = getClientFullnameFromID(clientID); $$("scheduler").$$("client").setValue(clientFullName); console.log('clientFullName: '+clientFullName); });

[getClientIDFromEventID() and getClientFullnameFromClientID() are two functions I have written]

The correct ‘clientFullName’ is written to console.log, but it seems to be being written over when the edit form is shown, as the value goes back to “”.

How should I be setting the text field so it shows the correct value once show() is called?


If you want to set some value for item property, you should set it directly for the item in scheduler datastore:

$$(“scheduler”).item(id).client = “…”;

To update all views in scheduler: $$(“scheduler”).setDate();