Submission Form issue

Status
Not open for further replies.

mk13

New Member
When I put this code in Submission Form, a value become to another value.
e.g.
I set like this:
$d=mktime(0,0,0,$d[1]-10,$d[2],$d[0])
And save it , then I went back to the setting and look at the code like this:
$d=mktime(0,0,0,$d[1]-10,$d[2],$d[1])

A value(marked red) automatically was changed.
And these were treated Date Element for setting and the staging was onBeforestore
Whole code is below:
('_JEXEC') or die ('Restricted access');
$origin = JRequest::getVar('db_event___begin',post);
return $formModel->updateFormData('db_event___dummy',$origin,true);
$d=explode("-",substr('$origin',0,10));
$d=mktime(0,0,0,$d[1]-10,$d[2],$d[0]);
return $formModel->updateFormData('db_event___date',$d,true);
$t=explode(":",substr('$origin',11,0));
$t=mktime($t[0],$t[1],0,0,0,0);
return $formModel->updateFormData('db_event___time',$t,true);
Any technique was needed for using mktime() in Submission Form ?
 
Well I haven't looked in depth what your code is doing but only the first three lines will run....

Code:
return $formModel->updateFormData('db_event___dummy',$origin,true)  ;

This return will end your script as it returns the value.... so anything after it will be ignored.

http://php.net/manual/en/function.return.php


So maybe this why you don't see the desired results?
 
About the automatically changing index: I can remember fabrik2 threads where Hugh was chasing this effect.

A workaround was to add blanks to the index, so maybe
$d=mktime(0,0,0,$d[ 1 ]-10,$d[ 2 ],$d[ 0 ]);
will help.
 
@troester, That was right. we should do like [ 0 ] not [0], spacer was needed.
@felixkat, Yes second and Third codes was needed a formatting of date, So I added Date Function like : $d=date("Y-m-d",$d);
Then it works. Thank you for guys help!
 
I coulud to do like this:
Copy a Datetime to another element
- type : Date element to Date element
- Form Submission : onBeforestore
- Format : Save As Local set in Date Element, not GMT
PHP:
('_JEXEC') or die ('Restricted access');$origin=JRequest::getVar('db_event___origin_raw');return $formModel->updateFormData('db_event___Copy_raw',$origin,true);

Copy a Date to another element as 10 days ago()

- type : Date element to Date element
- Form Submission : onBeforestore
- Format : Save As Local set in Date Element, not GMT
PHP:
('_JEXEC') or die ('Restricted access');$origin = JRequest::getVar('db_event___origin');$d=explode("-",substr("$origin",0,10));$d=mktime(0,0,0,$d[ 1 ],$d[ 2 ]-10,$d[ 0 ]);return $formModel->updateFormData('db_event___OneDay',$d,true);
Copy a time to another element as ONLY time
- type : Date element to Field element
- Form Submission : onBeforestore
- Format : Save As Local set in Date Element, not GMT
PHP:
('_JEXEC') or die ('Restricted access');$origin = JRequest::getVar('db_event___origin');$t = date("H:i",strtotime($origin));return $formModel->updateFormData('db_event___OneTime',$t,true);
 
About the automatically changing index: I can remember fabrik2 threads where Hugh was chasing this effect.

A workaround was to add blanks to the index, so maybe
$d=mktime(0,0,0,$d[ 1 ]-10,$d[ 2 ],$d[ 0 ]);
will help.

Yup, that's still an issue in F3.

And ... I could absolutely kick myself. Whilst chasing a totally different bug in the backend a few weeks ago, I ran across what is almost certainly the line of code causing that problem. I meant to comment it with a "FIXME" and come back to it, but apparently I didn't comment it. And now I have no clue where it was.

::sigh::

-- hugh
 
I don't mind about that.
Maybe just put the thing to Wiki as Fabrik Coding Rule. That is it :)
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top