About fields and field api

26 views
Skip to first unread message

Ravi

unread,
May 13, 2013, 3:25:13 PM5/13/13
to quicka...@googlegroups.com
Chris,
I've begun testing your app for one of the websites I'm trying to put together for a non-profit organization. I had a few questions and hope that you can answer them.

1. Is the fields/fields api only applicable to the Users module? Meaning 'expanding' the fields can only be done on the users table?
2. How do we define relationships between new tables (from custom modules) that we add to the existing tables? For example, our charity has mulitple locations and volunteers 'belongTo' one (but various chapters. I was thinking of writing a module that will add a 'Chapter' module but then I want the volunteer who are stored in the 'users' table to 'belongTo' a chapter.

I've read the documentation but couldnt find the solution (may be I missed it)

Any reply would be greatly appreciated. Thanks so much for developing the QuickApps CMS.

regards,
Ravi

Christopher Castro

unread,
May 13, 2013, 4:10:13 PM5/13/13
to quicka...@googlegroups.com
Field API allows you to "expand" any Model (typically, Model are tables in your DB), so no, it's not limited to the User table only.
Actually the "Content Types" system is purely based on Field API.

---

I dont know if I get it right:

a. Volunteers - belongsTo - Location ?
b. "Volunteers belongsTo many Chapter"  (which is the same: Chapter - hasMany - Volunteers)
c. Location - hasMany - Chapter ??


---

So, you would like to add some input fields to your User information form? where you could select Location (selectbox) and multiple Chapters (check boxes).

User Form:
Location: [ Select Box ]
Chapter:  [X] Chapter1
              [_] Chapter2
              [X] Chapter3
              [_] Chapter4

I believe the best solution is create a Field to handle that kind of info.
For instance, Location & Chapers can be handled using Taxonomy Field, so you have 50% of the work done.

Field API may be tricky to work with, so a simpler solution is create a completely independent Module, with its own User table (Volunteers).
(QACMS modules are basically cakephp plugins)


Regards!


2013/5/13 Ravi <rkand...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "QuickApps CMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quickapps-cm...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Christopher Castro.
Analista Programador Senior PHP/MySQL
Pamplona, España
QuickApps.es
https://github.com/QuickAppsCMS/QuickApps-CMS

Ravi

unread,
May 13, 2013, 4:21:41 PM5/13/13
to quicka...@googlegroups.com, ch...@quickapps.es
Chris,
Thanks for the reply. It great to know the Fields api can be applied to any table. In the admin backend I only see links to

<mysite>/admin/user/fields

How do I manage the fields for other Models? I'm sorry to ask a silly question, I'm still learning.

Also, what I'm looking for is this

Volunteer belongsTo (only 1) Chapter.  (Chapter and Location are the same in my case)
Chapter hasMany Volunteers

I want to be able to add fields to the Users table to add the 'chapter info' which I will do using the input form. If I understand you right, you are saying, if I have to implement any Model relationships (like hasMany or belongsTo) I need to write a separate Module. Am I right?

thanks,
Ravi

Christopher Castro

unread,
May 13, 2013, 4:32:25 PM5/13/13
to quicka...@googlegroups.com
How do I manage the fields for other Models? I'm sorry to ask a silly question, I'm still learning.
This is not posible via backend GUI, you must use Field API at programming level (as part of a Module for example)

---

 if I have to implement any Model relationships (like hasMany or belongsTo) I need to write a separate Module. Am I right?
yes, thats right

---

Volunteer belongsTo (only 1) Chapter.  (Chapter and Location are the same in my case)
Chapter hasMany Volunteers

For what I see, you could do this simply using Taxonomy Field.

1. Create a new Vocabulary named "Locations"
2. Add a new "Term reference" field to Users
    2.1 Configure as:
            Vocabulary: Select the new vocabulary you just created, "Locations"
            Element Type: Checkboxes/radio buttons
            Number of values: Unlimited

Now add yout Locations to yout "Locations" vocabulary, then in User's form you will be able to select many Locations as you wish for each user.


2013/5/13 Ravi <rkand...@gmail.com>

Ravi

unread,
May 13, 2013, 4:59:47 PM5/13/13
to quicka...@googlegroups.com, ch...@quickapps.es
Thank you for the reply. It makes a lot of sense. I can now focus on writing a module rather than thinking I'm missing something. :)
Reply all
Reply to author
Forward
0 new messages