change date and username

nadjak

Member
Hi,
I have to elements in my form which should be updated by updating the form.
My settings are:

1element:
Plugin user, data username
update on edit yes

2element:
Plugin date,
Default to current date No
alwax return todays date Yes

In my database this two fields are only updated by changing the form.
But in the detail view of the data, this two fields show the current date and the current user. But there I want to display the data from the database (to show who and when the dataset was changed)

Can anybody help me, how to realise this?
Thank you
Nadja
 
Last edited:
Update:
the date is displayed right, if I have some data in this field in the database.
For example: I fill in my form, the date is filled in automatically.
In my detail view it's displayed right.
If I make some changes the date is updated and displayed right in the detail view.
But I habe some older entries in the database without an input in this field.
So in my detail view the today date is shown and not nothing. Can I change this? If there is noch data in Database I want to display nothing.

And the other field is automatically filled by the username. If I change the dataset, the username should be the username from the person who chances the dataset.
So I set the element "update on edit" to yes.
But in my detailview I always see in this field MY username and not the username which is in the database.
If the field has in the database no data it is also set to my username. But I want to display nothing if nothing is in the database.

Has anybody an idea ?
Thank you Nadja
 
I'm still searching a solution. Now it is a little bit urgent!
Has really nobody an idea?
Thank you
Nadja
 
For your username are you using the jUser plugin? I don't think this is what you want. Just use a text field and in the default section of the element put this: return '{$my->name}';

For new forms you will get the name of the user, for updates you will get whatever is in the database.
 
Yes, I use the juser-Plugin.
But I want that the element "autoupdate" to the current user if the dataset is modified.
For example.
I fill in the form and my username ist "admin".
So in the field is my name "admin".
In two days the user "test" change my dataset. Now the field should fill in the username "test".
I hope you understand what I mean.
Always the last user who changed the dataset should be written in this field.

I tried your way: If I view the detail view of the dataset I see the userID from the user, who changed the dataset last time (That is what I want :))
But if I want to change the dataset, this field is not be updatet. It is a field set to readonly. It should change the user by itself.

Thank you
Nadja
 
You could add a form php plugin to set the value of name to the current userID. Use onBeforeProcess and update the value before it is saved to the database.
 
oh! Please, can you help me to do this?
I don't know how to display the new name in the field.
I want to display it in the form, not only change by saving.
So I think the onBeforeProcess is too late, and I should tage the onLoad. Or I am wrong?

I think in the php plugin first I need to get the current user with
<code>
$user = JFactory::getUser();
$name = $user->get('name');
</code>
Is this right?
But how can I set my element (user_last_modified) to the $name?

Thank you so much
Nadja
 
Hi Nadja,
I'm also new to FABRIK,, but I have something like this just setup ... so here's how it should work ....

PHP:
$formModel->updateFormData('yourTableName___yourFieldName', $name);
My Plugin is called at "onBeforeProcess" ...

Hope this helps.
Manfred.
 
I have in my form > plugins >php > onLoad (I also testet onBeforeProcess) this php-code:
PHP:
$user = JFactory::getUser();
$name = $user->get('username');
$formModel->updateFormData('tabname___name ', $name);
But if I change the dataset I see in my form the old entry and if I save my changes, the old entry is still in the database and not changed to my new username.
Can anybody help me, to find the fault?
Thank you
nadja
 
Hi Nadja,
could you add this line into your php-file before all of your current code and add or update a record?
PHP:
echo '<pre>';print_r($this->data);echo '</pre>';exit;
Then copy the output as an answer here ... if the output contains any "sensitive" data(passwords / personal data /etc.) please replace that with ****

EDIT: The interesting part of the output starts after:
[Submit] =>

If the output contains a lot of data try to only paste the lines "around" those containing the fieldname you are trying to change.

After that comment out that line or otherwise you will not be able to add/update data to your list!

Cheers,
Manfred.
 
Thank you cheesegrits. But in joomla no update for fabrik is shown.
Should I make the changes by myself in the user.php?

Thank you Manfred for your help. I made the output, but I hope cheesegrits solved my problem :)

Nadja
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top