How to transfer a field to another field
How to transfer a field to another field
When I use DataTables editor to receive data in the PHP backend,The value of GQ field is obtained by the difference between xdtime and wctime, not from the input value, My method is like this:
->fields(
Field::inst( 'xdtime' ),
Field::inst( 'wctime' ),
Field::inst( 'gq' )
->setValue(round((strtotime(Field::inst( 'wctime' ))-strtotime(Field::inst( 'xdtime' )))/3600/24)),
but it's wrong,How is the right way to get it?
Greetings
This question has accepted answers - jump to:
Answers
I want the value of the GQ field to come from the difference between the other two date fields
You need to use event handlers for this. For example you might use
preCreate
andpreEdit
to set the value based on the data that is passed into the event handlers for each row. That allows it to handle multi-row editing as well.Allan
Thank you for your reply,But I have a key questions
example:
In this example, the field “created_ By ” set to $_ Session ['username '] value, but if I want “ create_ By” is set to another field in the same table, such as "first_name",How do I rewrite this code?
Is the data you want it to be sit to being submitted from the client-side? If so use
$values['email']
for example.Allan
Great. Thinks,Most of the problems have been solved. Editing and adding are OK. There are still problems in in-line editing. There is no problem in pop-up editing alone. However, when editing directly Inline, the post information cannot be received and an error," a system error has occurred will be reported. How can I modify it so that it can also be edited in-line
What is the response from the server when that happens? You can check using the network tab in your browser's inspector. The "A system error..." message means that the server responded with invalid JSON, so we need to know what it is actually responding with. Hopefully and error message that can be addressed.
Allan
A system error has occurred (more information). Yes, the error message I get in the browser now is an error message on line 120. The code on line 120 is:
->setValue((round(strtotime($values['wctime'])-strtotime($values['xdtime']))/3600/24));**
Detailed errors are as follows:
Allan Thanks , I using inline editing
I found it. Submit it with all the data. It's OK. Thanks
Nice one - thanks for posting back.
Allan
thanks