Page 1 of 1

[opgelost] formbuilder to list sinds CMSMS 2.x

Posted: Thu Feb 11, 2016 4:03 pm
by pedes
In vorige versies van CMSMS gebruikte ik een UDT om de ingave van een formbuilder form op te slaan in een ListIt2 instantie .
Dit werkte perfect!

Sinds de komst van CMSMS 2.x kan je ListIt2 niet meer gebruiken en gebruik ik Easylist (some ook al LISE), maar daar werkt de voormalige UDT niet meer.
Iemand die weet hoe ik de UDT aanpas zodat deze ook werkt voor Easylist en het nieuwe LISE.

Dit is de gebruikte UDT

Code: Select all

/**
 * Load wanted ListItExtended instance, where you wan't to save items.
 * If instance can't be loaded, it will silently return.
 */
$mod = cmsms()->GetModuleInstance('ListIt2instantienaam');
if(!is_object($mod))
    return;
 
/**
 * Intitate empty item using API.
 */    
$obj = $mod->InitiateItem();
/**
 * Fill previously initiated ListIt2Item object with values from form submission.
 * NOTICE: All params that are not known by ListIt2Item object are going to ignored.
 */        
$obj->title = $params['email'];
 
foreach($params as $key => $value) {
    if(isset($obj->fielddefs[$key]))
        $obj->$key = $value;
}
 
/**
 * Save this object to database by using ListItExtended API.
 */        
$mod->SaveItem($obj);
Alvast dank voor de hulp,
Grtz
Peter

Re: formbuilder to list sinds CMSMS 2.x

Posted: Fri Feb 19, 2016 4:42 pm
by Jo Morg
There is just a minor adjustment needed in the UDT in order for it to work with LISE instances:

Code: Select all

/**
 * Load wanted ListItExtended instance, where you wan't to save items.
 * If instance can't be loaded, it will silently return.
 */
$mod = cmsms()->GetModuleInstance('ListIt2instantienaam'); //<-- this needs to change to the real instance name, probably LISE<instance_name>...
if(!is_object($mod))
    return;
 
/**
 * Intitate empty item using API.
 */    
$obj = $mod->InitiateItem();
/**
 * Fill previously initiated ListIt2Item object with values from form submission.
 * NOTICE: All params that are not known by ListIt2Item object are going to ignored.
 */        
$obj->title = $params['email'];
 
foreach($params as $key => $value) {
    if(isset($obj->fielddefs[$key]))
        $obj->$key = $value;
}
 
/**
 * Save this object to database by using ListItExtended API.
 */        
$mod->SaveItem($obj);
Other than that the API is the same...

Re: formbuilder to list sinds CMSMS 2.x

Posted: Tue Feb 23, 2016 4:12 am
by pedes
Hi Jo Morg,

Thank you for your reply, I had the instance name ok, but I missed the email field, that was mentioned in the UDT. So this is working... but

As this is a form for putting a comment in a review list, I would like to put the status off the in input standard off or not actif.
Normal this is standard on active.

Is there a way to put this in the UDT or in some other way.
So that I can decide if the input can be active and viewed on the website?

Kind regards
Peter

Re: formbuilder to list sinds CMSMS 2.x

Posted: Wed Feb 24, 2016 5:34 pm
by Jo Morg
I didn't test it but try:

Code: Select all

$obj->active = FALSE;
... just before the "$mod->SaveItem($obj);". It should work...

Re: formbuilder to list sinds CMSMS 2.x

Posted: Thu Feb 25, 2016 4:31 pm
by pedes
Nice, very nice...
Thank you Jo Morg for your solution .

I can recomment this UDT to all who is using LISE or previous fork of this module.

Kind regards