Welcome, Guest
Username: Password: Remember me

TOPIC: Fill a foreign value (N:m) directly in the form

Fill a foreign value (N:m) directly in the form 08 Feb 2016 16:29 #13805

  • krasy
  • krasy's Avatar
  • Offline
  • Premium Member
  • Posts: 90
  • Thank you received: 8
  • Karma: 5
Hi,
during the work, i ve found something like this:



thx, for investigation,

btw there is also an issue
when you put 'Created by>userneme' into combobox through FK
same what happened on the image but when dragging the proper thing:
discount values>Created by>username
we get user 'ID' not 'username' in Form in sandbox.


PS I'll make some FAQ about ACLs in J-cook and Joomla in general,
I have some fresh insights that could be helpful.:)
The administrator has disabled public write access.

Fill a foreign value (N:m) directly in the form 09 Feb 2016 12:19 #13806

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
This is absolutly normal.

In a form you cannot access more than 1 FK Level.
If you want to achieve this, you have to instance a list group (available in its ajax version)

How come ? What do you try to do ?
This is a non-sense to set up a foreign key value in this way. It would need to update another table, and it is not possible.
Actually, more ahead, you shouldn't have to encounter such case.
In your case, you want to set the discount value in the same time than the discount code, but trough a M:n table, I think I understand a bit your problematic; but there isn't a simple way to do it.
You need to create N:m link, and manage differently when you affect a new value to your form.
It is easy in some hand with the N:m system, but it is not vossible to fill a cross element in the same time than the main form. In your case, I don't see any possibility to enter this "value" field in the form.

If you want adding multiple values, the best is to turn yourself to ajax to acheive that.
If you need just ONE value at a time, you would better have to create an extra field, wich will be treated in PHP by the controller (playing with models)

If you choose the second solution, I can help you. For the first one (ajax), it is more free and I cannot propose you any solution at the moment.

That's it.
Coding is now a piece of cake
Last Edit: 09 Feb 2016 12:20 by admin.
The administrator has disabled public write access.

Fill a foreign value (N:m) directly in the form 09 Feb 2016 13:36 #13807

  • krasy
  • krasy's Avatar
  • Offline
  • Premium Member
  • Posts: 90
  • Thank you received: 8
  • Karma: 5
let me explain what im;trying to do,
because I have forgotten to add one pice of the puzzle:

-that's form/choice for the author of record in "discount value"
-published:0

From the beginning:

in "discount" we have

id:1 -- value: 5%
id:2 -- value:10%
id:3 -- value:20%
...


in "discount value"
we have the information which discount is allowd for the reseller:
created by admin from admin panel with autor edited to be proper reseller:


id:1 -- FK:reseller1 -- FK:5 % -- author:reseller1
id:2 -- FK:reseller1 -- FK:10% -- author:reseller1
id:3 -- FK:reseller1 -- FK:20% -- author:reseller1
id:4 -- FK:reseller2 -- FK:5 % -- author:reseller2
...


in "codes":
there is:

code:328fjdsalhg --- and id from "discount values" <--- that record is made by reseller on his own from frontend

because reseller is an author of only some records from "discount values"
he should see only 5%, 10%, 20% from public "discount" table

as Fk:discount value>FK:discount>value

if there was no author it would make sense for me to display all values: 5%, 10%, 20% and 5% again.

why do you think its wrong?
The administrator has disabled public write access.

Fill a foreign value (N:m) directly in the form 10 Feb 2016 10:56 #13808

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
That's a N:m


The only thing is that you need is to propagate accesses.
There is a model function ready for that for, but not ready for N:m
So you have to code manually.

The content of the N:m is prepared in the relation.php form field. Through the "model.php" field.
You can add a static parameter for this "special behaviour". Personally , I would work with states.
So the XML form is statically set up with a state var.
The state var do not handle dynamic info, just set for exemple : "coupon" = true

The relation.php form field, is just sending the sate to its model.
And then, read from the model, you change the SQL depeding if this state var is set.

Am I clear ?
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.066 seconds

Get Started